Inventor Customization

Reply
*Expert Elite*
jtylerbc
Posts: 890
Registered: ‎09-01-2010
Message 1 of 3 (317 Views)
Accepted Solution

iLogic - Test for iPart

317 Views, 2 Replies
01-25-2013 11:28 AM

I have a fairly simple external iLogic rule I've been working on (and using) for the last couple of days, which I would like to add some additional functionality to.  The rule is run on a part file, - it then looks at that part's Part Number iProperty, goes to an Excel price list, retrieves the corresponding Cost and Comments fields from the spreadsheet, and writes these to the appropriate iProperty values in the part.

 

 

Target = iProperties.Value("Project", "Part Number")

i = GoExcel.FindRow("X:\R&D\R&D Structure\Fitting Cost Estimator.xls", "Price List", "PART #", "=", Target)

Cost = GoExcel.CurrentRowValue("ESTIMATED COST")
Comment = GoExcel.CurrentRowValue("COMMENTS")

iProperties.Value("Project", "Estimated Cost") = Cost
iProperties.Value("Summary", "Comments") = Comment

InventorVb.DocumentUpdate()



If Cost = 0 Then
	If Comment = "PART MISSING FROM PRICE LIST"
		MessageBox.Show("This fitting is missing from the price list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
		
	Else
		MessageBox.Show("This fitting has no price entered in the price list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
	
	End If

End If

 

This rule is really only intended to update data for non-iPart components in our central library of purchased parts.  However, this library contains a mix of normal parts and iParts, and it would be very easy to accidentally run the rule on an iPart.  Is there something simple that could be added to the rule to check if the active document is an iPart, and skip it if so?

John Tyler
Inventor 2015
Windows 7 64 Bit

Hi jtylerbc,

 

You can use something like this:

 

Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
If partDoc.ComponentDefinition.IsiPartFactory _
Or partDoc.ComponentDefinition.IsiPartMember Then
Return 'do nothing
Else
MessageBox.Show("This is NOT an iPart", "Title")
End If

 

 

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

 

 

 

*Expert Elite*
Curtis_Waguespack
Posts: 2,987
Registered: ‎03-08-2006
Message 2 of 3 (313 Views)

Re: iLogic - Test for iPart

01-25-2013 11:41 AM in reply to: jtylerbc

Hi jtylerbc,

 

You can use something like this:

 

Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument    

If partDoc.ComponentDefinition.IsiPartFactory _
Or partDoc.ComponentDefinition.IsiPartMember Then
Return 'do nothing
Else
MessageBox.Show("This is NOT an iPart", "Title")
End If

 

 

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

 

 

 



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





*Expert Elite*
jtylerbc
Posts: 890
Registered: ‎09-01-2010
Message 3 of 3 (300 Views)

Re: iLogic - Test for iPart

01-25-2013 12:34 PM in reply to: Curtis_Waguespack

Curtis,

 

Thanks, that works great.  I modified it a bit to give a message box if run on an iPart, instead of just a Return.  Later on I may add an additional check to exclude assemblies as well, but since there is currently only one assembly in this entire library folder, that can wait for now.

 

 

John Tyler
Inventor 2015
Windows 7 64 Bit
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!