update iPART part number as filename

update iPART part number as filename

vitor2HXBF
Explorer Explorer
466 Views
3 Replies
Message 1 of 4

update iPART part number as filename

vitor2HXBF
Explorer
Explorer

Hi everyone, I have used this line of code for consistent Part Numbers when saving files:

iProperties.Value("Project", "Part Number")= ThisDoc.FileName

 

as suggest by autodesk itself: https://knowledge.autodesk.com/support/inventor/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-...

 

The problem is when I use this rule in an iPart it breaks the part Number because of Index.

Is there an easy fix to this code?

0 Likes
467 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Can you explain where you need the filename changed? Is the iPart factory in a library or in your workspace folder? The iPart member name or partnumber can be set in the iPart factory table. No ilogic should be needed. If you can supply some more information with images etc the answer can correctly target your request. 

 

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 4

vitor2HXBF
Explorer
Explorer

@A.Acheson  I want to prevent others from changing the filename without changing the iProperties partnumber, this worked as the link suggested  "How to update iProperties Part Number so that it always reflect the current file name". the exception is when i try saving an iPart.

 

There is nothing much to say besides repeating the article steps. Then follow this steps from your Part:

Save as filename.ipt > Manage > Create iPart > insert Row 

Now the child PartNumber is filename-01, filename-02.

Run article's Rule0 (iProperties.Value("Project", "Part Number")= ThisDoc.FileName) 

Now the child PartNumber is "filename" and not "filename-01".

if you try to change the iPart child in the Table, this is the prompt:

vitor2HXBF_1-1657798470929.png

 

 I work aroud the Rule0 to check if is iPart then it will not override the PartNumber:

	oPartDoc = ThisApplication.ActiveDocument    
	If oPartDoc.ComponentDefinition.IsiPartFactory _
	Or oPartDoc.ComponentDefinition.IsiPartMember Then
	
	'Basically I want this
	
	Else
	iProperties.Value("Project", "Part Number") = ThisDoc.FileName
	End If

 I want that commented line of code that considers Indexes

0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

Perhaps a simple solution is to have the file name column as the part number column instead of the normal method where the member column dictates the filename.

 

From what I hear the i factory is a writable file and not stored in a library. 
Here is the API help for the iPart factory

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