All,
Good morning! I used this post here to extract all the commands from Inventor and I'm trying to figure out how to edit a BIM Connector via iLogic. The command I found is the following:
AEC_Exchange:Command:Connector:Edit :: Edit Connector
Unfortunately, I don't know how to execute it. I use the code sequence below and it throws an error, I suspect because it does not recognize the feature name (the problem line is in the 3rd line from the bottom of the second box of code). If anyone can provide some examples or point me in the correct direction, as to how to edit a BIM connector via iLogic, I would really appreciate it. Thanks in advance for any assistance, hope all is well and have a most blessed day!
Peace,
Pete
' Get the CommandManager object. Dim oCommandMgr As CommandManager oCommandMgr = ThisApplication.CommandManager ' Get the collection of control definitions. Dim oControlDefs As ControlDefinitions oControlDefs = oCommandMgr.ControlDefinitions 'Define the individual control definition to launch a command. (We'll use this to edit BIM Connectors later) Dim oControlDef As ControlDefinition
'Index the Electrical Counter Elec_Count = Elec_Count + 1 'Create Electrical Connector Definition Dim oElecConn As BIMElectricalConnectorDefinition oElecConn = oPartDocBIM.Connectors.CreateElectricalConnectorDefinition(Elec_Coll) oElecConn.SystemType = BIMElectricalSystemTypeEnum.kPowerBalancedElectricalSystemType 'Add the Electrical BIM Connection oPartDocBIM.Connectors.Add(oElecConn) 'Change the name of the Electrical Connector 'The ".Parent" portion accesses the higher level BIMConnector object, where the name can be changed oElecConn.Parent.Name = "Elec_Conn_" & Elec_Count 'Open and edit the new Electrical BIM Connector oControlDef = oCommandMgr.ControlDefinitions.Item("AEC_Exchange:Command:Connector:Edit(oElecConn.Parent.Name)") ' Execute the command. Call oControlDef.Execute
Solved! Go to Solution.
Solved by JelteDeJong. Go to Solution.
I'm not very familiar with working with BIMComponents, but I may be able to help a little with your code.
Is the extent of your final code's purpose just to activate that Edit command, or do you want to actually make some edits to the Connector, within this code?
If you are planning on editing the Connector with code, I would just suggest further modifying its definition.
You can also 'expose' alot of its values to the Parameters. You could then use either a Form or series of InputBox lines to further 'edit' the connector.
I condensed and slightly renamed a few things within your code while trying to troubleshoot your issue.
I also removed the custom coding at the end of the ControlDefinition, because it just wont accept that.
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oPartDocBIM = oPDef.BIMComponent
Dim oCDs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
'Define the individual control definition to launch a command. (We'll use this to edit BIM Connectors later)
Dim oEditCommand As ControlDefinition
'Index the Electrical Counter
Elec_Count = Elec_Count + 1
'Create Electrical Connector Definition
Dim oElecConnDef As BIMElectricalConnectorDefinition = oPartDocBIM.Connectors.CreateElectricalConnectorDefinition(Elec_Coll)
oElecConnDef.SystemType = BIMElectricalSystemTypeEnum.kPowerBalancedElectricalSystemType
'Add the Electrical BIM Connection
Dim oElecConn As BIMConnector = oPartDocBIM.Connectors.Add(oElecConnDef)
'Change its name
oElecConn.Name = "Elec_Conn_" & Elec_Count
'Define the Connector Edit command
oEditCommand = oCDs.Item("AEC_Exchange:Command:Connector:Edit")
' Execute the command.
oEditCommand.Execute
If using a Form or series of questions wouldn't work, and you really want to go the Command route, perhaps you need to include the newly created Connector in a HighlightSet, or SelectionSet, just prior to executing the command.
Wesley Crihfield
(Not an Autodesk Employee)
Thanks @WCrihfield! You can probably tell I'm not a programmer, so I appreciate all the help I can get 😀 I've been piecing together code from a few different sources, but I have yet to find anything on editing existing BIM connectors via iLogic.
I do indeed want to launch the Edit command on a particular connector or highlight the surface first and then create / edit the connector. I've figured out how to select the surface that I want and create the connector based on that surface, but want to give the users flexibility to configure the connector as desired. My goal is to create some hybrid automation on converting shrinkwrapped assemblies to Revit families. Just plodding my way through the code.
I'll give your code a try and let you know if I have any questions. Thanks for the help and have a most blessed day!
Peace,
Pete
@WCrihfield, Thanks for your code suggestions, but I've run into a snag. No matter what I try, I cannot get either the selection code or the "Connector:Edit" code to work. However, if I assign the values via a text input box, then I can get it work. I believe the problem lies in the fact that the iLogic code runs OUTSIDE of the "BIM Content" environment, but the selection and editing of the Connectors, can only occur INSIDE the "BIM Content" environment. Does anyone know of a code snippet that would first activate the "BIM Content" environment, so I can perform the edits? I'll keep digging on my end, but up to this point, I've not been able to find code to do this. If you have any questions, please do not hesitate to contact me. Hope all is well and have a most blessed day!
Peace,
Pete
Sorry I couldn't be more help, but I'm just not familiar with the BIM environment.
I do have another iLogic code snippet you can play around with though.
The following line should 'activate' the BIM Environment.
ThisApplication.CommandManager.ControlDefinitions.Item("AEC_Exchange:Environment").Execute
As you said though, I'm not sure any further iLogic code past this will be of much use, as I'm not sure if you can do anything with iLogic while your in the BIM Environment. Perhaps a VBA macro or an Add-in is needed to manipulate things while your in the BIM Environment.
Wesley Crihfield
(Not an Autodesk Employee)
Thanks @WCrihfield! I'll give that a go and see if it works. Will let everyone know how it shakes out. Thanks for the ideas and have a most blessed day!
@WCrihfield, thanks for the information! I feel like I'm tantalizingly close, but am just stuck on not being able to edit the connector. To help get over the final hump, I'm including the screencast and attached file. If someone can please help me select and edit the BIM connector, I'd be super grateful! I'm hoping it's just something silly that I'm missing...
Thanks in advance for any assistance, hope all else is well and have a most blessed day!
Peace,
Pete
You where almost there i think. the problem here is that you cant select a node that is not visible. (like not visible because the parent node is not expanded.) I alterd your code to expand the parent nodes. I think it now does what you want. (also i cleaned the code a bit. I find it difficult to read the vba style of coding and i found some other things that i would different. I hope you dont mind. Anyway i marked the only important changes blue)
' Get the collection of control definitions. Dim oControlDefs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions ' check if this document is a part document If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then MessageBox.Show("The current document must be a part file", "Incorrect Document Type") Return End If 'Enter the BIM Content environment ThisApplication.CommandManager.ControlDefinitions.Item("AEC_Exchange:Environment").Execute() 'Access the Browser and Activate the "Bim Content" Browser Pane Dim oPartDoc As PartDocument = ThisDoc.Document Dim bps = oPartDoc.BrowserPanes Dim bimContentPane As BrowserPane = Nothing For Each BP As BrowserPane In bps ' the name is case sensitive original it worked only accidentally (BIM should be with capital letters)
' ' i made the if statement case insensitive ;-) If BP.Name.Equals("Bim Content", StringComparison.InvariantCultureIgnoreCase) Then BP.Activate() bimContentPane = BP End If Next 'Define the Appearance variables Dim oElecAppearance As Asset = oPartDoc.Assets.Item("Connection_Electrical") Dim oMechAppearance As Asset = oPartDoc.Assets.Item("Connection_Mechanical") Dim oPipeAppearance As Asset = oPartDoc.Assets.Item("Connection_Piping") 'Define the BIM Component Information Dim oPartDocBIM As BIMComponent = oPartDoc.ComponentDefinition.BIMComponent 'Check through each Face on the body and see if uses the special appearance. For Each oSrfBody As SurfaceBody In oPartDoc.ComponentDefinition.SurfaceBodies For Each oFace As Face In oSrfBody.Faces If oFace.Appearance.DisplayName = oElecAppearance.DisplayName Then Dim Elec_Coll As ObjectCollection Elec_Coll = ThisApplication.TransientObjects.CreateObjectCollection Elec_Coll.Add(oFace) 'Create Electrical Connector Definition Dim oElecConn As BIMElectricalConnectorDefinition oElecConn = oPartDocBIM.Connectors.CreateElectricalConnectorDefinition(Elec_Coll) oElecConn.SystemType = BIMElectricalSystemTypeEnum.kPowerBalancedElectricalSystemType 'Add the Electrical BIM Connection Dim con As BIMConnector = oPartDocBIM.Connectors.Add(oElecConn) con.Name = "Elec_Conn_" & oPartDocBIM.Connectors.Count 'Create a Browser Node and select the new connector via the Browser Dim oTopBrowserNode As BrowserNode = bimContentPane.TopNode For Each oNode As BrowserNode In oTopBrowserNode.BrowserNodes If Right(oNode.FullPath, 22) = "MEP System Connections" Then oNode.Expanded = True '<-- this is an important change Dim oSubNode As BrowserNode = oNode.BrowserNodes.Item(5) oSubNode.Expanded = True '<-- this is an important change Dim oConnNode As BrowserNode = oSubNode.BrowserNodes.Item(con.Name) oConnNode.DoSelect() 'Open and edit the new Electrical BIM Connector Dim oControlDef As ControlDefinition = oControlDefs.Item("AEC_Exchange:Command:Connector:Edit") ' Execute the command. oControlDef.Execute() End If Next End If Next Next
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
@JelteDeJong, that is brilliant! Gosh I always feel like I get so close and you definitely got me where I needed to be! As you can probably tell, I'm not a programmer 😁 so I'll definitely take your refinements into consideration. I was planning on building some subroutines anyway and I always appreciate advice from the experts. Thank you so much and have a most blessed night!
Peace,
Pete
@JelteDeJong & @WCrihfield, good morning! I really appreciate your help with this code, up to this point and has really gotten me SO close to the final goal. I've hit a snag, unfortunately, dealing with pausing the user code and would appreciate any help that you can pass along. I wasn't sure if it was completely connected with this thread, so I started a different thread, which you can find here. Thanks in advance if you can take a look! Hope all is well and have a most blessed day!
Peace,
Pete
Can't find what you're looking for? Ask the community or share your knowledge.