Author Topic: More Piping Questions - MEP 2010  (Read 1015 times)

0 Members and 1 Guest are viewing this topic.

commodore

  • Newt
  • Posts: 51
More Piping Questions - MEP 2010
« on: February 17, 2011, 11:08:48 am »
I've been able to add pipe to MEP through vb.net.  I found out how to place the pipe on the correct system and use the correct style.  Unfortunately I can not find out how to apply the Routing Preference I need.  What's even worse is that it doesn't apply ANY Routing Preference which causes the Pipe Curve object snap to work on the pipe. 

Any thoughts or directions would be appreciated!

Helsinki_Dave

  • Guest
Re: More Piping Questions - MEP 2010
« Reply #1 on: February 21, 2011, 08:01:02 am »
..here's a guess. (I'm ACA not A)MEP

ConnectionComponentMember

which inherits from the Pipe member.

There is some material on MEP in Autodesk University ".NET Programming: A beginners guide" as given by Kevin Vandecar

I'm going to email Kevin once I get to first base so I don't look like a complete waste of time. I'm on ACA, and the help for this using .NET is as slim as for AMEP. I'll ask Kevin if he has any more material which he might be able to send through. He may be willing to free up a whole bunch more material, since it's clear that development on the API is well and truly over thanks to Revit.

commodore

  • Newt
  • Posts: 51
Re: More Piping Questions - MEP 2010
« Reply #2 on: February 24, 2011, 12:26:16 pm »
I looked at the ConnectionComponentMember on a MEP inserted pipe and came up with the attached screenshot.  Just like the documention from Kevin Vandecar mentions, I can see Gender, Domain, ConnectionType, etc.  The StyleId it returns takes me to the Connector Style and the SystemId is the same as the pipes.  But still nothing points me to the routing preference.

I did find an article on the Autodesk discussion site http://forums.autodesk.com/t5/AutoCAD-MEP/AutoCAD-MEP-2009-New-Features/m-p/2193548/highlight/true that talks about how "the Routing Preferences are also now stored on Pipe and Fittings" starting with 2009.




Jeff H

  • Needs a day job
  • Posts: 4543
Re: More Piping Questions - MEP 2010
« Reply #3 on: March 02, 2011, 09:29:55 pm »
Have you tried the Engineering Data of the Pipe

Code: [Select]
[CommandMethod("PipePref")]
        public void PipePref()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;       

            using (Transaction trx = db.TransactionManager.StartTransaction())
            {               
                ObjectId pipeId = ed.GetEntity("Select Pipe").ObjectId;
                Member member = trx.GetObject(pipeId, OpenMode.ForRead) as Member;
                DataRecord dataRecord = PartManager.GetEngineeringData(member);
                DataField routingPeference = dataRecord.DataFields.FindByContext(Context.RoutingPreferenceId);
                ed.WriteMessage("\nThe Routing Preference is " + routingPeference.ToString());
                trx.Commit();           
            }           
        }

Jeff H

  • Needs a day job
  • Posts: 4543
Re: More Piping Questions - MEP 2010
« Reply #4 on: March 02, 2011, 11:03:21 pm »
See if this will change routing preference.
Using out of the box stuff


*************Edit *************

Need this
Code: [Select]
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Aec.DatabaseServices;
using Autodesk.Aec.Building.DatabaseServices;
using PipeDbServies = Autodesk.Aec.Building.Piping.DatabaseServices;
using ArchDbSrvcs = Autodesk.Aec.Arch.DatabaseServices;
using ObjectId = Autodesk.AutoCAD.DatabaseServices.ObjectId;
using Autodesk.Aec.Building.ApplicationServices;


Code: [Select]
[CommandMethod("PipePref")]
        public void PipePref()
        {

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Transaction trx = db.TransactionManager.StartTransaction())
            {
                PipeDbServies.DictionaryPipePartRoutingPreferencesStyle pipePrefDic = new PipeDbServies.DictionaryPipePartRoutingPreferencesStyle(db);
                ObjectId newPipePrefId = pipePrefDic.GetAt("Brazed Copper");

                ObjectId pipeId = ed.GetEntity("Select Pipe").ObjectId;
                Member member = trx.GetObject(pipeId, OpenMode.ForWrite) as Member;
                DataRecord dataRecord = PartManager.GetEngineeringData(member);

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

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

                trx.Commit();
            }
        }

Jeff H

  • Needs a day job
  • Posts: 4543
Re: More Piping Questions - MEP 2010
« Reply #5 on: March 02, 2011, 11:27:05 pm »
It changes in the Properties Palette. I just have not messed with piping much mainly electrical.

Here is VB since that is what I think you prefer

Code: [Select]
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports ObjectId = Autodesk.AutoCAD.DatabaseServices.ObjectId
Imports Autodesk.Aec.DatabaseServices
Imports ArchDbSrvcs = Autodesk.Aec.Arch.DatabaseServices
Imports PipeDbServies = Autodesk.Aec.Building.Piping.DatabaseServices
Imports Autodesk.Aec.Building.DatabaseServices
Imports Autodesk.Aec.Building.ApplicationServices

<Assembly: CommandClass(GetType(MEPExamplesVB.MyCommands))>

Namespace MEPExamplesVB

    Public Class MyCommands


        <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