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: 

Run rules in assembly parts, only when needed.

6 REPLIES 6
Reply
Message 1 of 7
GavoGarmo
488 Views, 6 Replies

Run rules in assembly parts, only when needed.

Hi,

 

I have some assemblies that are made of iLogic parts. The code within the assemblies causes a common external rule to run in each of the parts to update the part's metadata (descriptions, part numbers ect.) to relect any changes to the part.

 

However, when a change is made to the assembly, not all the parts are effected and yet my code will still run the external rule within the uneffected parts. This slows things down some, but more problematic is the fact that the uneffected parts need to be checked out/revised, even though they themselves haven't changed.

 

Is there a way of reorganising my code so that external rules are only run in parts that are effected by the assembly change?

 

Thanks in advance.

6 REPLIES 6
Message 2 of 7
xiaodong_liang
in reply to: GavoGarmo

Hi,

 

if you could share a demo, it will be helpful to know how the structure of the rules is and how the changes triggers the updating. I am thinking there may be a possibility you could set some global flags to indicate if it is neccessary to run the main code of the external rule or, in the external rule, determine which parts need to be updated.

 

Anyway, I'd suggest you provide your code demo. We could take a look how to meet your requirement.

Message 3 of 7
GavoGarmo
in reply to: xiaodong_liang

Thank you for the reply

 

Attached is a simplified assembly that has exactly the same structure as out larger ones.

 

Currently we are not using triggers as we've been advised it is better to directly run rules through the code.

 

In this example the frame has four sides, each has an external code run within it when the assembly code is run.

 

Currently, if only the width parameter is altered the external rule is still run in all four parts. It would solve our problem if we could get the code to only run in the two parts effected by a change in width.

 

GavoGarmo

 

 

 

 

Message 4 of 7
GavoGarmo
in reply to: GavoGarmo

For some reason my attachments are not displaying on the post. Is there another way I could get the .zip file to you?
Message 5 of 7
xiaodong_liang
in reply to: GavoGarmo

Hi GavoGarmo,

 

you could try with rename the extension name of the file to a kind of image such as jpg, and make sure the size does not extend to the size limitation. I can rename it to zip after downloading.

 

Another option is to upload to a public disk such as SkyDrive of hotmail.

Message 6 of 7
GavoGarmo
in reply to: xiaodong_liang

https://skydrive.live.com/redir?resid=9E44D0D6D0A08ABE!189&authkey=!AGnWQp2865xYxww

 

Hopefully this should get the file to you.

 

Thanks for your help

 

GavoGarmo

Message 7 of 7
xiaodong_liang
in reply to: GavoGarmo

You have to provide one more global file to store the last valus of Width and Length. When the rule of assembly runs, check the values with current values of Params. If only Width changes, run the two comps, If Length changes, run the other two comps.

 

The following is a code demo for your reference. Assume you have created a txt file "GlobalV.txt" in project path and have filled in two lines with an initial values e.g. 

 

0

0

 

'get project path
Dim oProjPath 
oProjPath = ThisApplication.DesignProjectManager.ActiveDesignProject 

'get full path of "GlobalV.txt"
Dim strGobalVFileName
strGobalVFileName = oProjPath.WorkspacePath & "GlobalV.txt"  

If Not System.IO.File.Exists(strGobalVFileName) Then
 ' if  "GlobalV.txt" does not exist
  MsgBox ("GlobalV.txt does bnot exist in work path!")
Else
   ' read "GlobalV.txt"
   
    Dim lines() As String 
	lines = System.IO.File.ReadAllLines(strGobalVFileName)
     'assume the first line is for Width  
    globalV_Width = lines(0)
	'assume the second line is for Length  
	globalV_Length = lines(1)  
	
 
	' if global width is different to current width
	' run the corresponding componenents
	If Width <> globalV_Width Then
	    Parameter("Top","G_L") = Width
        Parameter("Bottom","G_L") = Width
	    iLogicVb.RunRule("Top","Specification")
		iLogicVb.RunRule("Bottom","Specification")		
		
	End If
	
	' if global length is different to current length
	' run the corresponding componenents
	If Length <> globalV_Length Then
	
	   Parameter("Left","G_L") = Length
	   Parameter("Right","G_L") = Length
	   iLogicVb.RunRule("Left","Specification")
	   iLogicVb.RunRule("Right","Specification")
	End If 
	
	' now update "GlobalV.txt"  with newest Width and Length for next use.	
 
	lines = System.IO.File.ReadAllLines(strGobalVFileName)

    lines(0) = Width
	lines(1) = Length
    System.IO.File.WriteAllLines(strGobalVFileName, lines) 
End If

 

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

Post to forums  

Autodesk Design & Make Report