copying parts list across sheets

copying parts list across sheets

Anonymous
Not applicable
518 Views
4 Replies
Message 1 of 5

copying parts list across sheets

Anonymous
Not applicable

i have this code here which references a drawing view on sheet:1, i am trying to get it to reference a parts list instead. i want to be able to copy a parts list over to a different sheet.

can anyone help?

 

ActiveSheet = ThisDrawing.Sheet("Sheet:2")
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument

ActiveSheet = ThisDrawing.Sheet("Sheet:1")
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

ActiveSheet = ThisDrawing.Sheet("Sheet:2")

Dim o1Sheet As Sheet
o1Sheet = oDrawingDoc.ActiveSheet
ActiveSheet = ThisDrawing.Sheet("Sheet:1")

               
 ' 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)

ActiveSheet = ThisDrawing.Sheet("Sheet:2")

    ' Set a reference to the sheet's border
    Dim oBorder As Border
    oBorder = o1Sheet.Border
    
    Dim oPlacementPoint As Point2d
    
        xrev = oBorder.RangeBox.MaxPoint.X
        yrev = oBorder.RangeBox.MaxPoint.Y
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
   
    ' Create the parts list.
    Dim oPartsList1 As PartsList
    oPartsList1 = o1Sheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)

oPartsList1.Style.UpdateFromGlobal 

InventorVb.DocumentUpdate()

 

0 Likes
Accepted solutions (1)
519 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

It looks like you can already find the PartsList, so maybe you are looking for this?

PartsList.CopyTo(oOtherSheet)

 

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oPList As PartsList
Try
	oPList = oSheet.PartsLists.Item(1)
Catch
	MsgBox("No PartsList on active sheet.  Exiting rule.", , "")
	Exit Sub
End Try
For Each oSht As Sheet In oDDoc.Sheets
	If oSht IsNot oSheet Then
		oPList.CopyTo(oSht)
	End If
Next

 

 

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Anonymous
Not applicable

thanks for the response. the code worked for me but i was wondering if there is a way to pick which pages the parts list copies too?

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Sure.  In this version of the code, after I retrieve the Parts List from the active sheet, I then loop through all the sheets, adding their names to a List, then present the List to the user, so they can choose one.  Then I use that chosen name to specify the sheet to copy the parts list to.  It worked in my tests, so I'm hoping it will also work for you.

Here's the new iLogic rule code.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oPList As PartsList
Try
	oPList = oSheet.PartsLists.Item(1)
Catch
	MsgBox("No PartsList on active sheet.  Exiting rule.", , "")
	Exit Sub
End Try
Dim oSheetNames As New List(Of String)
For Each oSht As Sheet In oDDoc.Sheets
	If oSht IsNot oSheet Then
		oSheetNames.Add(oSht.Name)
	End If
Next
Dim oSName As String = InputListBox("", oSheetNames, "", "SHEET NAMES", "CHOOSE A SHEET")
If String.IsNullOrEmpty(oSName) Then Exit Sub
oPList.CopyTo(oDDoc.Sheets.Item(oSName))

 

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

Anonymous
Not applicable
THANKS THIS SOLVED MY ISSUE
0 Likes