Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 1 of 5 (1,095 Views)
Accepted Solution

ilogic code to fix part numbers / revision number

1095 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



*Expert Elite*
PaulMunford
Posts: 913
Registered: ‎11-13-2006
Message 2 of 5 (1,077 Views)

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

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*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 3 of 5 (1,068 Views)

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
dclunie
Posts: 70
Registered: ‎03-26-2008
Message 4 of 5 (1,050 Views)

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*
PaulMunford
Posts: 913
Registered: ‎11-13-2006
Message 5 of 5 (1,037 Views)

Re: ilogic code to fix part numbers / revision number

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

He's the man :smileywink:

 

 

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!
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.