Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
70 Posts
2 Kudos
Registered: ‎03-26-2008
Post 1 of 5
Accepted Solution

ilogic code to fix part numbers / revision number

1171 Views, 4 Replies
04-11-2012 10:21 PM

Hi

 

I am after some help writing a ilogic rule to look at all part numbers on .ipt DocumentType = 12290

workflow is needed is to find all .ipt within assemblies and if part number on .ipt does notch match file name (without extension) then add.

 

Also on seperate rule if rev number equals (blank) or - then revision number on all .ipt to equal 1

 

Any help would be appreciated

 

Dave



Hi dclunie, 

 

Here's a sample rule to do this. And thanks to Paul for the recomendation.

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
'kAssemblyDocumentObject = 12291
If openDoc.DocumentType = 12291 Then
'Iterate though the part files in the assembly
For Each docFile In openDoc.AllReferencedDocuments
'kPartDocumentObject = 12290
If docFile.DocumentType = 12290 Then
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
'returns file name with extension
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'returns the number of characters in the file name
nameLen = Len(docFName)
'trims off the file extension (last 4 characters)
nameNoExtension = Left(docFName,nameLen-4)
'set part number to file name (without extension)
if iProperties.Value(docFName,"Project", "Part Number") <> nameNoExtension then
iProperties.Value(docFName,"Project", "Part Number") = nameNoExtension
else
end if
'check for empty Rev #
if iProperties.Value(docFName,"Project", "Revision Number") = "" then
iProperties.Value(docFName,"Project", "Revision Number") = 1
else
end if
'check for empty description
if iProperties.Value(docFName,"Project", "Description") = "" then
'get a description from the user
myDescription = InputBox("Enter Description.", "Description - "& docFName, iProperties.Value(docFName,"Project", "Description"))
iProperties.Value(docFName,"Project", "Description") = myDescription
else
end if
End If
Next
Else
MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!")
End If

 

Thank's very much for the code it works perfect and really fast ,it is appreciated

 

Dave

*Expert Elite*
940 Posts
198 Kudos
Registered: ‎11-13-2006
Post 2 of 5

Re: ilogic code to fix part numbers / revision number

04-12-2012 05:20 AM in reply to: dclunie

Curtis Waguespaeck has a lot of great information on iLogic on his blog:

http://inventortrenches.blogspot.co.uk/2011/08/copy-design-and-revision-rolling-with.html

 

Check it out

CSO

The CAD Setter Out Blog @CadSetterOut

Inventor Surfacing | AutoCAD | CAD Standards

Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
*Expert Elite*
3,002 Posts
1,702 Kudos
Registered: ‎03-08-2006
Post 3 of 5

Re: ilogic code to fix part numbers / revision number

04-12-2012 08:14 AM in reply to: dclunie

Hi dclunie, 

 

Here's a sample rule to do this. And thanks to Paul for the recomendation.

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document 

'kAssemblyDocumentObject = 12291 
If openDoc.DocumentType = 12291 Then
	'Iterate though the part files in the assembly
	For Each docFile In openDoc.AllReferencedDocuments	
		'kPartDocumentObject = 12290 
		If docFile.DocumentType = 12290 Then	
			
			'format  file name		
			Dim FNamePos As Long
	            	FNamePos = InStrRev(docFile.FullFileName, "\", -1)		         
	            	Dim docFName As String
	            	'returns file name with extension
			docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
			'returns the number of characters in the file name
			nameLen = Len(docFName)
			'trims off the file extension (last 4 characters)
			nameNoExtension = Left(docFName,nameLen-4)
                      	
			'set part number to file name (without extension)
        			if iProperties.Value(docFName,"Project", "Part Number")  <> nameNoExtension then
        			iProperties.Value(docFName,"Project", "Part Number")  = nameNoExtension
        			else 
        			end if
        			
			'check for empty Rev #
			if iProperties.Value(docFName,"Project", "Revision Number") = "" then
			iProperties.Value(docFName,"Project", "Revision Number") = 1
			else
			end if
			
			'check for empty description
			if iProperties.Value(docFName,"Project", "Description") = "" then
			'get a description from the user
			myDescription = InputBox("Enter Description.",  "Description - "& docFName,  iProperties.Value(docFName,"Project", "Description"))
			iProperties.Value(docFName,"Project", "Description") = myDescription
			else 
			end if	
		End If 		
	Next	
Else	

MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!")
End If 

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Valued Contributor
70 Posts
2 Kudos
Registered: ‎03-26-2008
Post 4 of 5

Re: ilogic code to fix part numbers / revision number

04-12-2012 09:35 AM in reply to: Curtis_Waguespack

Thank's very much for the code it works perfect and really fast ,it is appreciated

 

Dave

*Expert Elite*
940 Posts
198 Kudos
Registered: ‎11-13-2006
Post 5 of 5

Re: ilogic code to fix part numbers / revision number

04-12-2012 12:18 PM in reply to: dclunie

He's the man :smileywink:

 

 

CSO

The CAD Setter Out Blog @CadSetterOut

Inventor Surfacing | AutoCAD | CAD Standards

Please use the Mark Solutions! Accept as Solution or Give Kudos! Kudos functions - Thank you!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post