Adding balloons and parts list to drawing being auto generated from assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!