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: 

Selecting Civil 3D Point Objects

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
On-Point
1938 Views, 8 Replies

Selecting Civil 3D Point Objects

I've been writing AuoLISP code for several years, but I'm iun the process of migrating to the .NET API for my code in Civil 3D. I need to write a command that will create some custom text based on the properties of a pair of Civil 3D point objects. Is there any code examples that show how to filter a selection set for Civil 3D point objects and then access the properties of the selected points?

 

I'm just looking for some code that would get me started in the right direction.

 

Thanks.

 

Landon

8 REPLIES 8
Message 2 of 9
Jeff_M
in reply to: On-Point

To get a selection set of CogoPoints:

Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionOptions prOpts = new PromptSelectionOptions();
prOpts.MessageForAdding = "\nSelect points: ";
prOpts.MessageForRemoval = "\nRemove points: ";
TypedValue[] filter = { new TypedValue(0, "AECC_COGO_POINT") };
SelectionFilter ssFilter = new SelectionFilter(filter);
PromptSelectionResult res = null; res = ed.GetSelection(prOpts, ssFilter);

 

Then loop through the selected objects, knowing they are all CogoPoint objects due to the filter used:

 

using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
  foreach (ObjectId id in res.GetObjectIds())
  {
      CogoPoint pt = (CogoPoint)id.GetObject(OpenMode.ForRead);
      ed.WriteMessage("\nPoint Number: {0}, Elevation: {1}, Northing: {2}, Easting: {3}",     pt.PointNumber.ToString(), pt.Elevation.ToString("F2"), pt.Northing.ToString("F2"), pt.Easting.ToString("F2"));
  }
  tr.Commit();
}
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 9
Partha.Sarkar
in reply to: Jeff_M

You can use SelectionFilter and TypedValue as mentioned by Jeff.

 

You can see relevant code snippet in ADN AutoCAD DevBlog and ADN IM DevBlog.

 

Thanks,

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 4 of 9
On-Point
in reply to: Partha.Sarkar

Thanks for the example code Jeff and the links Partha. Looks like that is just what I needed to get going.

 

Landon

Message 5 of 9
ahmadizm
in reply to: Jeff_M

Hi Jeff,

 

Thanks for your code snippet -- it helped me a lot.

 

However, I have a question regarding selecting other objects. You mention "AECC_COGO_POINT" for cogo points, and I found "CIRCLE" and "LINE" as well as valid arguments. What is its equivalent for other entities? Particularly, I am trying to have the user select Survey Figures, but I don't know what to use as the second argument of TypedValue. "AECC_SURVEY_FIGURE" does not do the trick.

 

Your help is gratefully appreciated.

Message 6 of 9

I gave up on trying to find the correct name and use this instead:

 

RXClass.GetClass(typeof(FeatureLabel)).DxfName

 

this should return the name you seek. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 7 of 9
ASE-Rrenteria
in reply to: Jeff_M

Good evening,

 

I copied your code into my program and it works great for the selection part. For the iteration through the selection set I am having Visual Studio 2017 showing an error.

Apparently  

PromptSelectionResult

does not contain a definition for

GetObjectIds

 thus the line

foreach (ObjectId id in res.GetObjectIds())

 Gives an error. What am I missing?

 

Thank you.

Message 8 of 9
Jeff_M
in reply to: ASE-Rrenteria

Sorry, that should be res.Value.GetObjectIds()
Jeff_M, also a frequent Swamper
EESignature
Message 9 of 9
ASE-Rrenteria
in reply to: Jeff_M

Thank you Jeff_M, that did it.

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report