Adding balloons and parts list to drawing being auto generated from assembly

Adding balloons and parts list to drawing being auto generated from assembly

Thomas.Long
Advocate Advocate
1,070 Views
3 Replies
Message 1 of 4

Adding balloons and parts list to drawing being auto generated from assembly

Thomas.Long
Advocate
Advocate

I have a code that I've adapted from a code I found on here to auto generate a drawing after I finish my assembly. The assembly is going to be a dynamic assembly, with a myriad number of sizes and configurations and different parts involved. I know the type of parts I want to balloon, so I can signify based on the file name.

 

What I'm attempting to do right now is loop through the assembly and add a balloon to the drawing whenever I find a part that I've specified to be ballooned. The issue it states is "Public member 'View' on type 'Sheet' not found." It does this for both the parts list and the balloons. What I think is going on is that since the assembly is still technically the "active document," it doesn't have the types indicated for a drawing. 
 

 

SyntaxEditor Code Snippet

Function AddBalloons(oAsmDoc As AssemblyDocument)

    Dim oAsmDef As AssemblyComponentDefinition
    Dim oDrawDoc As DrawingDocument
    Dim oLeafOccs As ComponentOccurrencesEnumerator
    Dim oOcc As ComponentOccurrence
    Dim oSheet As Sheet
    
    oDrawDoc = ThisApplication.ActiveDocument
    
    'Assembly definition 
    oAsmDef = oAsmDoc.ComponentDefinition
     
    'Get all leaf occurrences of the assembly
    oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
    oSheet = oDrawDoc.Sheets.Item(1)
    
    For Each oOcc in oLeafOccs
        If Left(oOcc.Name,3) = "CCR" Then oSheet.View("VIEW1").Balloons.AttachToComponent(oOcc)
        If Left(oOcc.Name,3) = "MCR" Then oSheet.View("VIEW1").Balloons.AttachToComponent(oOcc)
    Next

End Function

SyntaxEditor Code Snippet

Function AddPartsList(DrawingDoc)
    
iLogicVb.UpdateWhenDone = True
    
    ' Set a reference to the drawing document. 
    Dim oDrawDoc As DrawingDocument
     oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.    
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
    
    ' Set a reference to the first drawing view on the sheet. 
    Dim oDrawingView As DrawingView
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to th sheet's border    
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    oPlacementPoint = oBorder.RangeBox.MaxPoint
    iLogicVb.UpdateWhenDone = True
        
    ' Create the parts list.    
    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

iLogicVb.UpdateWhenDone = True
End Function

 Any help is greatly appreciated! Thank you!

0 Likes
1,071 Views
3 Replies
Replies (3)
Message 2 of 4

Jon.Balgley
Alumni
Alumni

I'm pretty sure you need to use "DrawingViews.Item(n)" to access the views of the sheet.  You're using the Inventor API directly, not the iLogic classes.

 

Check this out, in a rule in a drawing document:

 

SyntaxEditor Code Snippet

v = ActiveSheet.View("VIEW1")
vv = ActiveSheet.View("VIEW2").View
MsgBox(v Is vv)

Dim doc as DrawingDocument
doc = ThisApplication.ActiveDocument
MsgBox(ThisDrawing Is doc)

 


Jon Balgley
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hello,

 

Have you already found a solution for this?
Would be very interested, because my position numbers disappear when configuring assemblies.

 

0 Likes
Message 4 of 4

Thomas.Long
Advocate
Advocate

Honestly, I never did solve this mostly because the positioning of all of my parts were never exactly the same so I was modifying them most of the time and it was glitchy at best. Apologies about that.

0 Likes