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: 

2013 - PointGroup via .NET API - not COM

5 REPLIES 5
Reply
Message 1 of 6
odoshi
350 Views, 5 Replies

2013 - PointGroup via .NET API - not COM

Anyone had luck making a point group via the .NET API in 2013?

 

I'm crashing out. But then, it's my first attempt, and I could have it all wrong... 🙂

 

 

CivilDocument

civilDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;

            System.Windows.Forms.

MessageBox.Show(civilDoc.PointGroups.Count.ToString());

           

ObjectId pointGrpId = ObjectId.Null;

            pointGrpId = civilDoc.PointGroups.Add(

"TEST");

            System.Windows.Forms.

MessageBox.Show(pointGrpId.ToString());

           

PointGroup pointGrp = (PointGroup)pointGrpId.GetObject(OpenMode.ForWrite);

           

StandardPointGroupQuery qry = newStandardPointGroupQuery();

            qry.IncludeRawDescriptions =

"TEST*";

            pointGrp.SetQuery(qry);

            pointGrp.Update();

 

 

 

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: odoshi

I have but don't have the code handy to check against yours. Have you looked at THIS blog post?

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

Yes, that is pretty much what I am doing. Although, I am running after a .NET context menu click.

 

I still got objectID's back for the point I selected but gettting an ID back from the PointGroups.Add() method seems spotty. I'll keep digging.

 

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
Message 4 of 6
Jeff_M
in reply to: odoshi

Isaac's example uses a method which has an internal Transaction which Commit()'s the PointGroup prior to using the SetQuery(), whereas you are doing it all in the same transaction. Perhaps this is the key? 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 6
Anonymous
in reply to: odoshi

Did you try to debug and see what line it is crashing ? Apparently I don't see anything wrong in your code snippet.

 

Here is a relevant blog post and you could try the same code using your data to see if that works fine.

 

http://adndevblog.typepad.com/infrastructure/2012/07/using-standardpointgroupquery-object-to-build-a...

 

Thanks,

Message 6 of 6
odoshi
in reply to: odoshi

It has something to do with how I am calling it from a context menu. After the context menu, a dialog appears. After it is closed, I add the group, but crash.

 

Running a seperate command line version works OK. So not an API bug in that regard.

 

Thanks,

Mike

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report