Hello,
I am trying to create some iLogic to automate the attachment of a sketch symbol to all feature control frames in a drawing. I am having some issues using a geometry intent with the Feature Control Frame object. The goal is to place the sketch symbol and attach to the feature control frame so that if the FCF is relocated manually, the symbol follows. The program crashed in the line that tries to add the sketch symbol leader, see below:
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSht As Inventor.Sheet
oSht = oDoc.ActiveSheet
'Add inspection bubble symbol from library (will not crash if symbol already added)
Dim oSketchSymLib As SketchedSymbolDefinitionLibrary
oSketchSymLib = oDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item("KTR Inspection Sketch Symbols")
Dim oSymDef As SketchedSymbolDefinition
oSymDef = oDoc.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, "Dimension Balloon", True)
Dim oSymbol As SketchedSymbol
Dim sPromptStrings(0) As String
Dim oPosition As Point2d
Dim fcf As FeatureControlFrame
dimCtr = 1
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
Dim oGeometryIntent As GeometryIntent
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim originPt As Point2d
Dim placePt As Point2d
'Scan all (non-hole) feature control frames and assign inspection bubbles
For Each fcf In oSht.FeatureControlFrames
If fcf.Notes = "" Then ' Change to check for balloons
sPromptStrings(0) = CStr(dimCtr)
oSymbol = oSht.SketchedSymbols.Add(oSymDef, oTG.CreatePoint2d(fcf.Position.X,fcf.Position.Y+1.2), 0, 1, sPromptStrings)
originPt = oTG.CreatePoint2d(oSymbol.Position.X,oSymbol.Position.Y)
oGeometryIntent = oSht.CreateGeometryIntent(fcf,fcf.Position)
oLeaderPoints.Clear
oLeaderPoints.Add(originPt)
oLeaderPoints.Add(oGeometryIntent)
oSymbol.Leader.AddLeader(oLeaderPoints) ' Code crashes here
oSymbol.LeaderVisible = False
dimCtr = dimCtr + 1
End If
Next