- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Forum,
Ik made this automation that creates a Grid:
Now I want to add a function that allows you to select 2 vertical sketch3d lines
The code will make a diagonal 3d sketchline from first line start point to second line end point
I want to have the user select the lines in the top assembly (D0175547.iam in this case)
Then after selecting 2 lines, I go to the "#Grid" document, and want to reselect the same 2 lines in context of that document
Now that fails.
It probably is some 'a workpoint proxy in a higher assembly is not the workpoint in the lower assembly' - kind of thing.
I prefer not to check XYZ of the start and endpoints of every line, or something complicated like that.
This is the crude code I'm doing this proof of concept with:
Dim layoutdocname As String = AddinGlobal.LayoutDoc.FullFileName
Dim oDef As AssemblyComponentDefinition = AddinGlobal.LayoutDoc.ComponentDefinition
Dim BaseOcc As ComponentOccurrence = oDef.Occurrences.ItemByName("#Base")
Dim GridDoc As PartDocument = Nothing
For Each oOcc As ComponentOccurrence In BaseOcc.SubOccurrences
If oOcc.Name = "#Grid" Then
GridDoc = oOcc.Definition.Document
End If
Next
Dim comps As ObjectCollection
Dim comp As Object
comps = AddinGlobal.InventorApp.TransientObjects.CreateObjectCollection
Dim osel As Inventor.SelectSet = AddinGlobal.LayoutDoc.SelectSet
osel.Clear()
While True
comp = AddinGlobal.InventorApp.CommandManager.Pick(SelectionFilterEnum.kSketch3DCurveLinearFilter, "Selecteer kolommen")
If IsNothing(comp) Then
Exit Sub
End If
comps.Add(comp)
osel.Select(comp)
If comps.Count = 2 Then Exit While
End While
Dim SketchLine1 As SketchLine3D = comps(1)
Dim SketchLine2 As SketchLine3D = comps(2)
AddinGlobal.InventorApp.Documents.Open(GridDoc.FullFileName, True)
Dim oSketch As Inventor.Sketch3D = GridDoc.ComponentDefinition.Sketches3D(1)
oSketch.Edit()
osel = GridDoc.SelectSet
osel.Clear()
For Each oLine As SketchLine3D In oSketch.SketchLines3D
If oLine Is SketchLine1 Or oLine Is SketchLine2 Then
osel.Select(oLine)
End If
Next
Solved! Go to Solution.