iLogic - Edit part list titles with part number

iLogic - Edit part list titles with part number

anthony_hendrick
Advocate Advocate
756 Views
7 Replies
Message 1 of 8

iLogic - Edit part list titles with part number

anthony_hendrick
Advocate
Advocate

Hi all,

 

I have drawings which contain a large number of assemblies. 

 

Each assembly comes from a master iassembly. 

 

Beside each assembly drawing view, I place the part list of that assembly.

 

I would ideally like the parts list title to display the part number of the assembly.

 

I am relatively new to ilogic and so any help would be greatly appreciated.

 

Thanks in advance

 

Anthony 

 

0 Likes
757 Views
7 Replies
Replies (7)
Message 2 of 8

SharkDesign
Mentor
Mentor

Try running this code on your drawing. You can save it as an external rule so you can run it on each one:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

Dim eachpl As PartsList
For Each eachpl In oSheet.PartsLists
	opart = eachpl.ReferencedDocumentDescriptor.DisplayName
    eachpl.Title = opart

Next
  Inventor Certified Professional
0 Likes
Message 3 of 8

anthony_hendrick
Advocate
Advocate
Oh that's very very close!!

However it is inserting the name of the iassembly file instead of the part number
0 Likes
Message 4 of 8

SharkDesign
Mentor
Mentor

Bit of a naughty way of doing it and maybe I'll get told off, but try this:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

Dim eachpl As PartsList
For Each eachpl In oSheet.PartsLists
	opart = eachpl.ReferencedDocumentDescriptor.DisplayName
	opn = iProperties.Value(opart & ".iam","Project", "Part Number")
    eachpl.Title = opn
	
Next
  Inventor Certified Professional
0 Likes
Message 5 of 8

anthony_hendrick
Advocate
Advocate

I just tried that there but unfortunately I am receiving the following error:

 

anthonyhendrick_0-1630931930283.png

 

I removed the " & ".iam" " to see what would happen and it worked but it then referenced the current iasssembly reference which was selected in the iassembly file into every part list. 

 

Really thank you very much for being so helpful James. If it doesn't work out it's obviously cool, I just thought it would be a very nice function to have. 

 

 

0 Likes
Message 6 of 8

SharkDesign
Mentor
Mentor

That's interesting, in mine it didn't pull the extension which is why I added it. 

That's the naughty bit, really you should find the instance name, but I'm not clever enough to do that. 

I've never written code for iAssemblies so that is probably where it is falling down and someone with more knowledge would probably get it working. 

 

Worked perfectly for me on normal assemblies though. 

 

  Inventor Certified Professional
0 Likes
Message 7 of 8

anthony_hendrick
Advocate
Advocate

Ah I see. Well thanks again for trying anyway.

 

I have still learned something which is good. 

0 Likes
Message 8 of 8

SharkDesign
Mentor
Mentor
0 Likes