Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - Test for iPart

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jtylerbc
990 Views, 2 Replies

iLogic - Test for iPart

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?

2 REPLIES 2
Message 2 of 3

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

 

 

 

Message 3 of 3

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.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums