Author Topic: How to offset polyline  (Read 2965 times)

0 Members and 1 Guest are viewing this topic.

Offline bcinnv

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
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!

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Re: How to offset polyline
« Reply #1 on: February 24, 2013, 07:53:31 AM »
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;

            }

        }

Offline bcinnv

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
Re: How to offset polyline
« Reply #2 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;

            }

        }

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Re: How to offset polyline
« Reply #3 on: February 26, 2013, 04:46:37 PM »
Absolutely no,
I'm just an old freak and forever beginner,
ha-ha :)