Inventor Customization

Reply
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 1 of 26 (664 Views)

iLogic Formual

664 Views, 25 Replies
04-26-2012 06:08 AM

I am trying to create a iLogic Rule that will measure the Length, Width and Thickness of a part and ut it into the custom fields we have. I am having a hard time rememebring how to get it to do it from the assembly level. I want to run this on the assembly and have it populate all the parts inside of it. The code below will do it for a part but what is it I add to get it to drill down into the assembly?

 

iProperties.Value("Custom", "THICKNESS")=Measure.ExtentsHeight

iProperties.Value("Custom", "WIDTH")=Measure.ExtentsWidth

iProperties.Value("Custom", "LENGTH")=Measure.ExtentsLength

 

Then I want ti to add this formyual to the Stock Number iProperty = <Length> X <Width>   I can get it to add the values but I can not get it to add the formual to the stock number.

 

I have 10,000 things to do and I can not concentrate long enough to figure this one out. Any help would be apprciated!

Andy Warren
BCDesign@bellsouth.net
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 2 of 26 (651 Views)

Re: iLogic Formual

04-26-2012 08:47 AM in reply to: andrew.warren

I am trying to get it to drill down into the part and fill out this info...

 

Format:HTML Format
Version:1.0
StartHTML: 165
EndHTML: 4413
StartFragment: 314
EndFragment: 4381
StartSelection: 314
EndSelection: 314

compo=Component.InventorComponent("PartA:1")

Try
iProperties.Value(compo, "Custom", "THICKNESS")=compoMeasure.ExtentsHeight

iProperties.Value(compo, "Custom", "WIDTH")=compoMeasure.ExtentsWidth

iProperties.Value(compo, "Custom", "LENGTH")=compoMeasure.ExtentsLength

Catch
EndTry

 

Andy Warren
BCDesign@bellsouth.net
Mentor
MegaJerk
Posts: 249
Registered: ‎01-26-2011
Message 3 of 26 (642 Views)

Re: iLogic Formual

04-26-2012 10:03 AM in reply to: andrew.warren

Something like : 

'Assuming that you have three custom Properties named "MegaThickness" , "MegaLength", and "MegaWidth" I believe this will do what you'd like
'
'Be sure to fill out the correct custom properties that you actually are using ;) 



iProperties.Value("PartA:1", "Custom", "MegaThickness") = Measure.ExtentsHeight
iProperties.Value("PartA:1", "Custom", "MegaLength") = Round(Measure.ExtentsLength,2)
iProperties.Value("PartA:1", "Custom", "MegaWidth") = Round(Measure.ExtentsWidth,2)

iProperties.Value("PartA:1", "Project", "Stock Number") = _ 
iProperties.Value("PartA:1", "Custom", "MegaLength") & " X " & iProperties.Value("PartA:1", "Custom", "MegaWidth") 

 

Does that help you?  

 

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 4 of 26 (638 Views)

Re: iLogic Formual

04-26-2012 11:12 AM in reply to: MegaJerk

Looks like what I want at the part leve... Will this drill down from an assembly or does it have to be ran from each part? I want to run it at the assembly level and let it fill these out...

Andy Warren
BCDesign@bellsouth.net
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 5 of 26 (636 Views)

Re: iLogic Formual

04-26-2012 11:19 AM in reply to: andrew.warren

MegaJerk it looks like you did somehting similar in this post... http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Run-ilogic-rule-in-each-part-from-the-... 

 

If I add my Custom prop iLogic to this will this do what I am talking about you think?

Andy Warren
BCDesign@bellsouth.net
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 6 of 26 (635 Views)

Re: iLogic Formual

04-26-2012 11:24 AM in reply to: andrew.warren

Something like this?

 

Dim openDoc As Document
openDoc = ThisDoc.Document

Dim docFile As Document 

If openDoc.DocumentType = 12291 Then

	For Each docFile In openDoc.AllReferencedDocuments
	
		If docFile.DocumentType = 12290 Then
		
		
			Dim FNamePos As Long
            FNamePos = InStrRev(docFile.FullFileName, "\", -1)	
						         
            Dim docFName As String
            docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
			
			If iProperties.Value(docFName, "Custom", "THICKNESS")="" Then
		
				iProperties.Value(docFName, "Custom", "THICKNESS") = Measure.ExtentsHeight 
				
			
			If iProperties.Value("Custom", "WIDTH")="" Then
				
				iProperties.Value("Custom", "WIDTH")= Measure.ExtentsWidth 
				
			If iProperties.Value("Custom", "LENGTH")="" Then
				
				iProperties.Value("Custom", "LENGTH")= Measure.ExtentsLength
						
			End If
		
		End If 
		
	Next
	
	Else
	
	MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exc​lamation)
	
End If 

 

Andy Warren
BCDesign@bellsouth.net
Mentor
MegaJerk
Posts: 249
Registered: ‎01-26-2011
Message 7 of 26 (631 Views)

Re: iLogic Formual

04-26-2012 11:32 AM in reply to: andrew.warren

The code that I posted should be ran from the assembly, and works. Did you actually try using it? Is the problem now that you would like to update all of the parts (and in turn : iProperties) that are in the assembly ?

The code you last posted could work with some tweaking, but I don't believe that it will work in that current state.  

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 8 of 26 (630 Views)

Re: iLogic Formual

04-26-2012 11:32 AM in reply to: andrew.warren

I guess I will also have to tell it to create the custom prop if it does not exist...

Andy Warren
BCDesign@bellsouth.net
*Expert Elite*
Curtis_Waguespack
Posts: 2,566
Registered: ‎03-08-2006
Message 9 of 26 (625 Views)

Re: iLogic Formual

04-26-2012 11:50 AM in reply to: andrew.warren

Hi andrew.warren,

 

Here is some information on creating the custom prop if it does not exist:

http://inventortrenches.blogspot.com/2011/05/use-ilogic-to-add-and-use-custom.html

 

Also just a heads up, I took a couple of minutes to look at your overall goal, an noticed that Measure.ExtentsHeight runs on the top level assembly (and therefore gathers it's height) even when iterating through the assembly components via the For Each. Unfortunately I didn't find a solution, but will post back I think of something.

 

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

For Each docFile In openDoc.AllReferencedDocuments		
	'format  file name		
	Dim FNamePos As Long
	FNamePos = InStrRev(docFile.FullFileName, "\", -1)		         
	Dim docFName As String	
	docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)       

	customPropertySet = docFile.PropertySets.Item _
	("Inventor User Defined Properties")

	'check for custom iprops and add them if not found
	Try
		prop1 = customPropertySet.Item(“Thickness")
		prop2 = customPropertySet.Item(“Width")
		prop3 = customPropertySet.Item(“Length")
	Catch
	' assume error means not found
		customPropertySet.Add("", “Thickness")
		customPropertySet.Add("", “Width")
		customPropertySet.Add("", “Length")
	End Try

	'get value from model
	prop1.value = Measure.ExtentsHeight
	prop2.value = Measure.ExtentsWidth 
	prop3.value = Measure.ExtentsLength
	
Next	

 



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





Distinguished Contributor
andrew.warren
Posts: 217
Registered: ‎02-07-2006
Message 10 of 26 (615 Views)

Re: iLogic Formula

04-26-2012 12:05 PM in reply to: Curtis_Waguespack

Yes that is what I want ti to to do, measure each part and return the part info into custom iprops as you created them. Dang, I did not want ti grabbing the assembly...

Andy Warren
BCDesign@bellsouth.net

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube