- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
So maybe it is better for something like this to use Factory Design add-in but I do not really like using that in 3D so I am trying to use the rule written below as a substitute for here and there.
In the same folder, I have my assy named "My Assy" and the component that I want to add, named "Cube".
Firstly Cube:1 is added and constrained in the correct place, then I start the code.
By using the code new cubes are added and the constraint "insert" is automatically activated (also with a locked rotation so no additional constraints are needed).
My problem is that I want to use a named entity when adding a constraint. The named entity is an edge that is defined in a Cube. Second edge I pick myself (one of the holes).
Since new cubes are added I think this code does not understand that it needs to pick a named entity from the last Cube that is added. But I am guessing here being a starter with this coding.
If anyone knows how to solve this please let me know.
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oDoc As PartDocument Dim oPath As String oPath = ThisDoc.Path Dim oName As String oName = "Cube.ipt" oDoc = ThisApplication.Documents.Open(oPath & "\" & oName, False) oDoc.Close Try i = oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Count + 1 Catch i = 1 End Try While True Dim componentA = Components.Add("Cube:" & i, oPath & "\" & oName, position := Nothing, grounded := False, visible := True, appearance := Nothing) Dim iLogicAuto = iLogicVb.Automation Dim namedEntities = iLogicAuto.GetNamedEntities(oDoc) Dim oEdge1 As Edge = namedEntities.FindEntity("My Edge") Dim oEdge2 As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPublicationEdgeFilter, "Pick second edge. press Esc to cancel") If oEdge2 Is Nothing Then Exit Sub oAsm.ComponentDefinition.Constraints.AddInsertConstraint2(oEdge1,oEdge2,True,0,True) oAsm.Update i = i + 1 End While
Solved! Go to Solution.