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!
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.
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;
}