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)
2. Running macro to make drawings appear (i did only 3 to show the idea)
Hope it's possible.
Thanks for all help in advance 😄
Solved! Go to Solution.
Solved by Michael.Navara. Go to Solution.
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
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...
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.
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.