- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All
My objective is to balloon all components in an assembly view. I have a rule that I believe it should work, but I keep getting an argument error when I go to add the balloons using the object collection.
This has got me stumped for now, any advice is appreciated.
' Add a balloon for each referenced component Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oView As DrawingView Dim oTG As TransientGeometry = ThisApplication.TransientGeometry ' Get the target view For Each v As DrawingView In oSheet.DrawingViews If v.Name = "TOP" Then oView = v Exit For End If Next Dim oAssemblyDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim oOccs As Inventor.ComponentOccurrences = oAssemblyDoc.ComponentDefinition.Occurrences Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection For Each oOcc As ComponentOccurrence In oOccs Try ' Try each edge until you find a drawable curve For Each oEdge As Edge In oOcc.SurfaceBodies.Item(1).Edges Dim oEdgeProxy As EdgeProxy oOcc.CreateGeometryProxy(oEdge, oEdgeProxy) Dim oCurves As DrawingCurvesEnumerator = oView.DrawingCurves(oEdgeProxy) If oCurves.Count > 0 Then Dim oCurve As DrawingCurve = oCurves.Item(1) Dim midPt As Point2d = oCurve.MidPoint oLeaderPoints.Add(oTG.CreatePoint2d(midPt.X, midPt.Y)) Dim intent As GeometryIntent = oSheet.CreateGeometryIntent(oCurve, 0.5) oLeaderPoints.Add(intent) Logger.Info("Point added for: " & oOcc.Name) Exit For End If Next Catch ex As Exception Logger.Error("Curve not found for " & oOcc.Name & ": " & ex.Message) End Try Next If oLeaderPoints.Count > 0 Then oSheet.Balloons.Add(oLeaderPoints) Else Logger.Error("No valid curves found for balloon placement.") End If
The error is:
"System.ArgumentException: The parameter is incorrect. (0x80070057 (E_INVALIDARG))
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Object[] aArgs, Boolean[] aArgsIsByRef, Int32[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
at Inventor.Balloons.Add(ObjectCollection LeaderPoints, Object VirtualComponent, Object Level, Object NumberingScheme, Object BalloonStyle, Object Layer)
at ThisRule.Main() in rule: Balloon, in document IMP-0600_ASSY CONFIG.idw:line 43
at Autodesk.iLogic.Exec.AppDomExec.ExecCodeHere()
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)"
Solved! Go to Solution.