.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
That is exactly the information that I was looking for! I had figured out how to get the part data from the pipe object from the ExportToExcel example but was still at a loss on how to extract the routing and system information. Thank you for the code!
I did look over the getengineeringdata example real quick but didnt see anything about routing preferences in it. I guess I should have compiled and ran the code and then I would have seen that it held the routing preference information. Lesson Learned.
One more quick question for you, how can you set the routing preference and the system definition?
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I did compile and run the GetEngineeringData example that ships with Autocad MEP and there is an error in the logic. They ask you to select any mep object and then it finds the engineering data by its context and its index number and then prints it out. The only problem is that the specific data that it is looking for seems to only be attached to a duct object. Maybe this was by design which is why they have several catch statements in the program but from the Comments in the program it is supposed to work for any MEP object.
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Its been a while but does this help?
http://www.theswamp.org/index.php?topic=37159.msg4
Mostly C# but here is some VB from link above
<CommandMethod("PipePrefVB")> _
Public Sub PipePrefVB()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim pipeId As ObjectId = ed.GetEntity("Select Pipe").ObjectId
Dim member As Member = trx.GetObject(pipeId, OpenMode.ForWrite)
Dim dataRecord As DataRecord = PartManager.GetEngineeringData(member)
Dim pipePrefDic As New PipeDbServies.DictionaryPipePartRoutingPreferences Style(db)
Dim newPipePrefId As ObjectId = pipePrefDic.GetAt("Brazed Copper")
Dim routingPeference As DataField = dataRecord.DataFields.FindByContext(Context.Routin gPreferenceId)
routingPeference.ValueObjectId = newPipePrefId
PartManager.SetPartData(member, dataRecord)
PartManager.SetEngineeringData(member, dataRecord)
trx.Commit()
End Using
End Sub
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I'm not surprised to see there is an error, but samples are always good for tweeking anyway!
I saw Jeff's post about setting the data on the part, that is what I was going to suggest the methods:
PartManager.SetPartData(member, dataRecord)
PartManager.SetEngineeringData(member, dataRecord)
The 'PartManager' object has quite a few very useful static methods.
In the code file that I attached earlier, there is a commented out foreach loop, if you uncomment it and run the command it will list all of the data and context and index number for each data item. Might be useful to know what other data you can get out of the dataRecord. That should work for any Member object, of course my code only passes a pipe object specifically.
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I forgot to mention, another way of accessing the various styles and definitions in the database is thru the Named Objects Dictionary, see the attached code file for a sample...
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for all the information! I was able to use the examples posted by Jeff and cadmeup and get the information I wanted from the pipeobject. I have not tried setting the system definition or routing preference but I plan to tackle that this weekend. I am having another issue but will start another thread so as not to run this one to death.
Thanks again for all of the help. It is difficult finding information on Autocad Architectural and Autocad MEP and the community seems to be the only place to find it right now without spending a ton of time researching.
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
That might have something to do with how horrible the documentation(if you can even call it that) for MEP and ARCH is.
The documentation just shows the signatures and have not updated or still send 2010 or 2009 with latest releases.
Re: Program crashes when trying to access modelspace
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The coding examples that ship with the product do help a little bit but even they are not documentated that well. I can't imagine that it would take someone with a good understanding of the .net api for MEP and Arch very long to go through and document them enough so someone could understand them better. Not everyone looking at the samples has a degree in computer science or a background in .net. I took a couple programming classes 20 years ago and decided to take the plunge into learning .net just recently. The basic concepts of programming are still there but learning the specifics of the api is proving quite challenging. MEP is a great program but could be so much more with just a little bit of tweaking.



