Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change layer of the parcel segment dependeing on it's parcel style?

2 REPLIES 2
Reply
Message 1 of 3
amyyoyo1
687 Views, 2 Replies

change layer of the parcel segment dependeing on it's parcel style?

Hi all, I am super new on .net. I watched some beginner level videos ,and I don't know if this is possible to do or not.

I am trying to build a rountie that will check the parcel style of the parcel segment and then change it's layer to the correct one.

At first I thought that should be easy to do, but what I don't know was autocad put all the information under parcel not the parcel segment.

I hoping using vb.net will be able to do something about it , and then I hit an other wall.

 

Dim prOpts AsPromptEditorOptions = NewPromptEntityOptions("\nSelect Parcel Segment: ")

 

        prOpts.SetRejectMessage("....no parcel segment found!")

        prOpts.AddAllowedClass(GetType(Autodesk.Civil.DatabaseServices.ParcelSegment), True)

 

for some reason visual studio is telling me that setrejectmessage and addalloedcalss are not a member of 'autodesk.autocad.editorinput.prompteditoroptions'.

Million Thanks for the help!

2 REPLIES 2
Message 2 of 3
Jeff_M
in reply to: amyyoyo1

You are using PromptEditorOptions, you need PromptEntityOptions.

 

The reason you can't get the Parcel from the ParcelSegment is because a segment can 'belong' to more than one parcel. I think the only way to do what you want is iterate the Parcels/ParcelLoops looking for the selected segment.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3
amyyoyo1
in reply to: Jeff_M

Thank you Jeff, you are a great help.

I search around the internet for parcel loop and I got a post that you anwered back at 2003 , not too sure if still useful not since .net have changed.

 /// <summary>
        /// Method to get the 2D Polyline represented by the Parcel
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public static Polyline BaseCurve2d(this Parcel parcel)
        {
            //This will fail to be set if there are any 3d segments
            Polyline poly = parcel.BaseCurve as Polyline;           
            if (poly != null)
                return poly;

            //3d segments found, loop through and create 2d vertices for new polyline
            poly = new Polyline();
            object comparcel = parcel.AcadObject;
            object[]args = new object[1];
            args[0] = 0;
            object loop = (object)comparcel.GetType().InvokeMember("ParcelLoops", System.Reflection.BindingFlags.GetProperty, null, comparcel, args);
           
            int count = (int)loop.GetType().InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, null, loop, null);
            for (int i = 0; i < count; i++)
            {
                args[0] = i;
                object segelement = (object)loop.GetType().InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, loop, args);
                double x = (double)segelement.GetType().InvokeMember("StartX", System.Reflection.BindingFlags.GetProperty, null, segelement, null);
                double y = (double)segelement.GetType().InvokeMember("StartY", System.Reflection.BindingFlags.GetProperty, null, segelement, null);
                double bulge = 0;
                try
                {
                    bulge = (double)segelement.GetType().InvokeMember("Bulge", System.Reflection.BindingFlags.GetProperty, null, segelement, null);
                }
                catch { }
                poly.AddVertexAt(i, new Point2d(x, y), bulge, 0, 0);
            }
            poly.Closed = true;
            return poly;
        }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report