.NET

Reply
*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 11 of 18 (201 Views)

Re: Program crashes when trying to access modelspace

01-31-2012 06:57 AM in reply to: cadMeUp

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?


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 12 of 18 (199 Views)

Re: Program crashes when trying to access modelspace

01-31-2012 07:18 AM in reply to: Keith.Brown

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.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 13 of 18 (188 Views)

Re: Program crashes when trying to access modelspace

01-31-2012 02:30 PM in reply to: Keith.Brown

Its been a while but does this help?

http://www.theswamp.org/index.php?topic=37159.msg423214#msg423214

 

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.DictionaryPipePartRoutingPreferencesStyle(db)
                Dim newPipePrefId As ObjectId = pipePrefDic.GetAt("Brazed Copper")

                Dim routingPeference As DataField = dataRecord.DataFields.FindByContext(Context.RoutingPreferenceId)
                routingPeference.ValueObjectId = newPipePrefId

                PartManager.SetPartData(member, dataRecord)
                PartManager.SetEngineeringData(member, dataRecord)

                trx.Commit()
            End Using
        End Sub

 

You can also find your answers @ TheSwamp
Valued Mentor
cadMeUp
Posts: 331
Registered: ‎05-11-2006
Message 14 of 18 (173 Views)

Re: Program crashes when trying to access modelspace

01-31-2012 03:21 PM in reply to: Keith.Brown

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.

Valued Mentor
cadMeUp
Posts: 331
Registered: ‎05-11-2006
Message 15 of 18 (160 Views)

Re: Program crashes when trying to access modelspace

02-01-2012 06:15 AM in reply to: Keith.Brown

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...

*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 16 of 18 (148 Views)

Re: Program crashes when trying to access modelspace

02-01-2012 08:10 AM in reply to: cadMeUp

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.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 17 of 18 (146 Views)

Re: Program crashes when trying to access modelspace

02-01-2012 08:16 AM in reply to: Keith.Brown

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.

You can also find your answers @ TheSwamp
*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 18 of 18 (144 Views)

Re: Program crashes when trying to access modelspace

02-01-2012 08:25 AM in reply to: jeff

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.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.