Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating Drawing views from part list

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
kacper_sikorskiD42JA
418 Views, 5 Replies

Creating Drawing views from part list

Hi,

 

I'm trying to write a ilogic code to automate the proccess of inserting drawings.

I want drawing views to appear based on the parts in part list that already exist. I don't need any particular placement (would be nice to have next below the previous one to don't make a mess).

 

IMPORTANT NOTE!

Those part list are in assembly drawing and part drawings as well!

 

Quick show how i imagined this

1. Empty sheet with part list and 1 view on it (the model that part list is from)

kacper_sikorskiD42JA_0-1715854172510.png

2. Running macro to make drawings appear (i did only 3 to show the idea)

kacper_sikorskiD42JA_1-1715854267297.png

 

Hope it's possible.

Thanks for all help in advance 😄

 

5 REPLIES 5
Message 2 of 6

You can use following rule to create drawing vies with fixed size

Sub Main()
    Dim drw As DrawingDocument = ThisDoc.Document
    Dim sheet As Sheet = drw.ActiveSheet
    Dim partsList As PartsList = sheet.PartsLists(1)
    
    viewY = sheet.Height - maxSize
    viewX = maxSize

    'Iterate PartsList
    For Each row As PartsListRow In partsList.PartsListRows
        Dim rowDocument As Document = row.ReferencedFiles(1).ReferencedDocument

        'Create drawing view
        CreateDrawingView(sheet, rowDocument)
    Next
End Sub

Private viewX As Double
Private viewY As Double
Private maxSize As Double = 3

Private Function CreateDrawingView(sheet As Sheet, rowDocument As Document) As DrawingView

    'Create position
    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(viewX, viewY)

    'Define next position
    viewY = viewY - maxSize - 1
    If viewY < 0 Then
        viewY = sheet.Height - maxSize
        viewX += maxSize + 1
    End If

    'Crate drawing view
    Dim rowView As DrawingView = sheet.DrawingViews.AddBaseView(rowDocument, position, 1, ViewOrientationTypeEnum.kTopViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)

    'Set scale
    Dim size As Double = Max(rowView.Height, rowView.Width)
    Dim scale = maxSize / size
    rowView.Scale = scale

    Return rowView
End Function
Message 3 of 6

Works perfect. Thank you ❤️
Message 4 of 6

If the idw contains multiple parts lists, is the a way to choose the the parts list that is used to generate the drawing views? i.e. I want to filter out the purchased parts and nuts a bolts...

Message 5 of 6

Which PartsList is used defines line 4. You can change the index or implement your own selection.

The second option is to check the referenced document (line 11). If the document doesn't meet the criteria you can continue For loop.

Message 6 of 6

Is the defined partslist denoted in brackets? ie (1) on line 4? 

Is it possible to physically select the partslist I want to use with a mouse click?  

 

Sorry this is very new to me 

Jamie

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report