can i put partlist on same position for every generated sheet?

can i put partlist on same position for every generated sheet?

ssiem
Contributor Contributor
485 Views
5 Replies
Message 1 of 6

can i put partlist on same position for every generated sheet?

ssiem
Contributor
Contributor

hello

i put part list for every sheet and its position is all same and i use A3 size only

i put part list for over 300pcs of sheet and i should change it sorting by part number and check change it automatically

it's finger sick

i think it can be solved by ilogic

Can I?

 

ssiem_0-1693113986533.png

 

0 Likes
Accepted solutions (1)
486 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Hi @ssiem 

 

You can pick up the border position using rangebox then calculate the required position after that. 

The API help here converted to ilogic for adding partslist.

 

    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    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. This assumes the first drawing
    ' view on the sheet is not a draft view.
    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
    
    If Not oBorder Is Nothing Then
        ' A border exists. The placement point
        ' is the top-right corner of the border.
        oPlacementPoint = oBorder.RangeBox.MaxPoint
    Else
        ' There is no border. The placement point
        ' is the top-right corner of the sheet.
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.height)
    End If
    
    ' Create the parts list.
    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

ssiem
Contributor
Contributor

Hello

I'm trying your rule and this is now 

 ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    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. This assumes the first drawing
    ' view on the sheet is not a draft view.
    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
    
    If Not oBorder Is Nothing Then
        
		' There is no border. The placement point
        ' is the top-right corner of the sheet.
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(41, 5.581325)
    Else
		' A border exists. The placement point
        ' is the top-right corner of the border.
        oPlacementPoint = oBorder.RangeBox.MaxPoint
        
    End If
    
    ' Create the parts list.
    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

it run well for sheet for part and not for assembly like this

ssiem_0-1693198334121.png

and I think it's not work through all of sheet just for a sheet that i browse

maybe I miss your note if it is tell me I'll read more meticulously 

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

Yes correct it is currently set up for active sheet. To loop over the sheets use this sample.

 

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

For Each oSheet As Sheet In oDrawDoc.Sheets
    Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
    ' Do something with view
Next

 

 

 

For assemblies you will need to set the options see api help here

Syntax

PartsLists.AddViewOrModel As Object, PlacementPoint As Point2d, [Level] As PartsListLevelEnum, [NumberingScheme] As Variant, [NumberOfSections] As Long, [WrapLeft] As Boolean ) As PartsList

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ssiem.  Here is another example iLogic rule you can review and test with.  One of the complicated things about that task is that we do not know which corner of your PartsList you have set as the 'insertion point' (where your mouse pointer is in relation to the PartsList when placing it manually.  That would tell us where within the area of the PartsList the PartsList.Position property is referring to.  I can see from your image examples that you want the lower right corner of the PartsList to be placed at the upper right corner of the TitleBlock on the sheet.  So I included some extra code in there to help overcome some of the unknown variables involve in this situation.  This code will attempt to iterate through every sheet in your drawing, and if the sheet does not already have a PartsList present, it will attempt to add one, the reposition it where you want it to be.  If the sheet already has a PartsList, or the sheet does not have any views, or the sheet does not have a TitleBlock present, it will skip to the next sheet.

 Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	Dim oASheet As Inventor.Sheet = oDDoc.ActiveSheet
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDDoc, "Add PartsLists - iLogic")
	For Each oSheet As Inventor.Sheet In oSheets
		oSheet.Activate
		If oSheet.PartsLists.Count > 0 Then Continue For
		If oSheet.DrawingViews.Count = 0 Then Continue For
		If oSheet.TitleBlock Is Nothing Then Continue For
		Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
		Dim oTBPos As Point2d = oSheet.TitleBlock.RangeBox.MaxPoint
		Dim oInsPt As Point2d = oTG.CreatePoint2d(oSheet.Width / 2, oSheet.Height / 2)
		Dim oPList As PartsList = oSheet.PartsLists.Add(oView, oInsPt)
		oDDoc.Update
		Dim oPL_Corner As Point2d = oTG.CreatePoint2d(oPList.RangeBox.MaxPoint.X, oPList.RangeBox.MinPoint.Y)
		Dim oPLPos As Point2d = oPList.Position.Copy
		oPLPos.TranslateBy(oPL_Corner.VectorTo(oTBPos))
		oPList.Position = oPLPos
	Next
	oASheet.Activate
	oTrans.End
	oDDoc.Update2(True)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6

ssiem
Contributor
Contributor

oh wow thank you it works very well

and Title block on my drawing is fake haha it's looks like Tiltle block but it's border

so i changed my template

it was good that you find out bottom right point is what i use to position it and explaining your code exception case

it so helpful 

0 Likes