03-07-2022
02:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-07-2022
02:30 AM
Hi,
I have an assembly with an attribute as shown
I want to add a balloon (No. 20) on a specific view ( detail E) automatically as shown
I am developing a code in VBA but got stuck when I try to execute the following line
Set oViewCurves = oView.DrawingCurves(oFaceProxy)
the error message that appears says Method 'DrawingCurves' of object "DetailDrawingView" failed
Here is my code to suggest for me an amendment
Thanks
Sub Balloons()
'Reference the file that's open
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'Reference the active Sheet
Dim oSheet As Sheet
Set oSheet = oDrawDoc.Sheets.Item(1)
'Reference the View we want
For i = 1 To oSheet.DrawingViews.Count
If oSheet.DrawingViews.Item(i).Name = "E" Then
Dim oView As DrawingView
Set oView = oSheet.DrawingViews.Item(i)
End If
Next
'Reference the Asembly Model on that Sheet
Dim oAssemblyDoc As Document
Set oAssemblyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'reference the assigned attribute on the Assembly Model
Dim oMainObjs As ObjectCollection
Set oMainObjs = oAssemblyDoc.AttributeManager.FindObjects("Balloon", "W01_Outer")
'reference to the Occerrence of tha Assembly Model
Dim oOcc As ComponentOccurrence
Set oOcc = oAssemblyDoc.ComponentDefinition.Occurrences.ItemByName(oMainObjs.Item(1).ContainingOccurrence.Name)
'reference to the Wanted Face
Dim oFace As Face
Set oFace = oMainObjs.Item(1)
'Promote to Proxy Face
Dim oFaceProxy As Inventor.FaceProxy
Call oOcc.CreateGeometryProxy(oFace, oFaceProxy)
'Promote to an DrawingCurve on the View
Dim oCurves As DrawingCurve
Set oViewCurves = oView.DrawingCurves(oFaceProxy)
Set oCurves = oViewCurves.Item(1)
End Sub
Solved! Go to Solution.