Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bcinnv

Pages: [1]
1
Blocks / Re: How to insert multiline attributes
« on: November 18, 2013, 02:30:59 PM »
Thanks bud! You always have the answer :)

2
Hatching / Re: Create associative hatch
« on: March 26, 2013, 01:21:28 PM »
Thanks fixo!  I'm tired of using the built in hatch functions... its automatic selection almost always crashes my session.

3
Windows forms / Re: Use dinamically created form in the project
« on: March 23, 2013, 08:01:11 AM »
Works great! Thanks!

4
Polylines / Re: Offset curve toward centroid
« on: March 18, 2013, 02:23:53 AM »
YOU GUYS ROCK!

5
Polylines / Re: Offset curve toward centroid
« on: March 17, 2013, 12:37:31 AM »
Thanks! But not always centroid I think, it's different for "I" and "moon" shapes.  Should just say Offset Polyline to Inside :). Works wonderfully though!

I do think I found a method to find the actual centroid... perhaps there's a way to find the offset closest to it and keep it?  I'm new at programming but here's the code I came up with to get the centroid for you to "fix" as you see fit :)

Code: [Select]
// get centroid of polygon


namespace BCCGETCENTROIDCOMMAND
{
    public class BCCGETCENTROIDCOM
    {

        [CommandMethod("BCC:CENTROID")]

        public static void BCCGETCENTROID()
        {

            // Get the current document and database

            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor ed = acDoc.Editor;
            Transaction tr = acCurDb.TransactionManager.StartTransaction();

            // Start a transaction

            using (tr)
            {

            SelectionFilter sf = new SelectionFilter(new TypedValue[1] { new TypedValue((int)DxfCode.Start, "LWPolyline") });//<<<--- a selection filter to get text only
            PromptSelectionResult objects = ed.GetSelection(sf);
            if (objects.Status != PromptStatus.OK) return;
            List<Polyline> polylines = new List<Polyline>();

            foreach (ObjectId oid in objects.Value.GetObjectIds())
            {
                DBObject ent = tr.GetObject(oid, OpenMode.ForWrite);
                Polyline p = ent as Polyline;

                // add the polylines to the array
                DBObjectCollection dbobjs = new DBObjectCollection();
                dbobjs.Add(ent);
                // create solid to get region and centroid
                Solid3d Solid = new Solid3d();
                Solid.Extrude(((Region)Region.CreateFromCurves(dbobjs)[0]), 1, 0);
                Point2d centroid = new Point2d(Solid.MassProperties.Centroid.X, Solid.MassProperties.Centroid.Y);
                Solid.Dispose();

                BlockTable acBlkTbl = tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord acBlkTblRec; acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                DBPoint acPoint = new DBPoint(new Point3d(centroid.X, centroid.Y,0));
                acBlkTblRec.AppendEntity(acPoint);
                tr.AddNewlyCreatedDBObject(acPoint, true);
                acCurDb.Pdmode = 99;
                acCurDb.Pdsize = 1;                     
            }

                // Save the new objects to the database
                tr.Commit();
            }

        }
    }
}


6
C# language / Re: How to offset polyline
« on: February 26, 2013, 12:25:17 PM »
You are one advanced programmer fixo

You may want to use command using API invoke method acedCmd
e.g. open desired block in block editor then perform this code
(it's not mine though)

Code: [Select]
        // Replace "accore.dll" by "acad.exe" for AutoCAD versions prior to 2013
        [System.Security.SuppressUnmanagedCodeSecurity]
        [DllImport("acad.exe", EntryPoint = "acedCmd", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
        extern static private int acedCmd(IntPtr resbuf);
        [CommandMethod("offpl")]

        public void cmdOffset()
        {

            ResultBuffer rb = new ResultBuffer();

            // RTSTR = 5005

            rb.Add(new TypedValue(5005, "_.OFFSET"));

            // start the insert command

            acedCmd(rb.UnmanagedObject);



            bool quit = false;

            // loop round while the insert command is active

            while (!quit)
            {

                // see what commands are active

                string cmdNames = (string)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CMDNAMES");

                // if the INSERT command is active

                if (cmdNames.ToUpper().IndexOf("OFFSET") >= 0)
                {

                    // then send a PAUSE to the command line

                    rb = new ResultBuffer();

                    // RTSTR = 5005 - send a user pause to the command line

                    rb.Add(new TypedValue(5005, "\\"));

                    acedCmd(rb.UnmanagedObject);

                }

                else

                    // otherwise quit

                    quit = true;

            }

        }

7
This site / Cool Site BTW
« on: February 24, 2013, 07:00:14 AM »
Was wanting to make a site specifically to be a library for 'How To' concerning coding in lisp and c# that I find and collect online. There is already a good start here. Thank you!

8
C# language / How to offset polyline
« on: February 24, 2013, 05:12:39 AM »
Anyone know of an example to offset a polyline that's added to the block record table via c#.net? I've tried to use the developer guide examples but errors out.  I'm looking for automatic selection for offsite side (either inner or outer, doesn't matter). Using centroid was always my preferred method in Lisp but it appears there isn't a centroid option with c# and polyline.

Thanks!

9
This site / Re: Welcome on the AutoCAD .NET developpers forums
« on: February 01, 2013, 04:42:21 AM »
Hello!

Pages: [1]