Vba or iLogic, parts list source

Vba or iLogic, parts list source

engilic
Advocate Advocate
489 Views
5 Replies
Message 1 of 6

Vba or iLogic, parts list source

engilic
Advocate
Advocate

Hi

 

Is it possible to get the source of the parts list, for which model it is?

 

have a lovely day

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @engilic.  Yes.  The PartsList object has a property called ReferencedDocumentDescriptor that will help in this situation.  That property returns a DocumentDescriptor object, which then has a lot of useful properties of its own, such as the FullDocumentName, and the ReferencedDocument

Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
oPList = oDDoc.ActiveSheet.PartsLists.Item(1)
oFDN = oPList.ReferencedDocumentDescriptor.FullDocumentName
MsgBox("PartsList source = " & oFDN, vbInformation, "")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

engilic
Advocate
Advocate

One more question if I can.

 

Is it possible to change the Source of the Parts List, both by code and also in Inventor, manually?

You can choose it when you put it, manually, but I do not see the option to change it even when you have views of more than one file in the drawing.

0 Likes
Message 4 of 6

engilic
Advocate
Advocate

thank you very much @WCrihfield 

0 Likes
Message 5 of 6

engilic
Advocate
Advocate

I thought it is not possible, just do not know why?

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Hi @engilic.  It is 'sort of' possible to change the source of a PartsList, but it is likely not as ideal as you are expecting.  It is similar to the effects of using the Manage tab > Modify panel > Replace Model Reference tool (manually), or replacing the model being referenced by a drawing view.  It seems to replace that model reference for the whole drawing document, not just for the PartsList, even though the process is started from the PartsList.  And, I believe the other model document you are specifying to be the replacement must be open (not necessarily the 'active' document though) for the replacement (by code) to work.

Below is an example of what I'm talking about:

Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
oPList = oDDoc.ActiveSheet.PartsLists.Item(1)
oRFD = oPList.ReferencedDocumentDescriptor.ReferencedFileDescriptor
oRFD.ReplaceReference("C:\Temp\Tests\TestAssembly 1.iam")
oDDoc.Update

It is most likely going to be more advantageous to capture the position of the existing PartsList, then delete it, then create a new one in its place that has the other model reference.  When creating a new PartsList by code, you can provide either a DrawingView object, or a Document object to the PartsLists.Add() method as its source.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes