Ilogic MakePath expression not working

Ilogic MakePath expression not working

benjaminPXQW3
Explorer Explorer
572 Views
9 Replies
Message 1 of 10

Ilogic MakePath expression not working

benjaminPXQW3
Explorer
Explorer

According to the Autodesk Inventor 2024 Help Guide:

MakePath

Defines the path to a component name in a subassembly. To specify the path, list all subassembly levels in the order they appear in the tree. This function is required if you want to specify a component name when the same name also exists elsewhere in the assembly.

Syntax

MakePath(“SubassemblyComponentName”,“PartComponentName”)

Examples

Component.Color(MakePath("SubAssem1:1", "Part2:1")) = “Green”
Component.IsActive(MakePath("SubAssem1:1", "SubSubAssem2:1", "Part2:1")) = “Yellow”

 My code below is supposed to change the color of the valves based on whether they are open (dark green) or closed (red) depending on the value of the parameter CYCLE.

If CYCLE = "FILTRATION" Then
Component.Color(MakePath("Tube & Pipe Runs", "NEW LINES:1", "4 inch s31 with haz loc s70:1"))  = "Dark Green"
Component.Color(MakePath("Tube & Pipe Runs", "NEW LINES:1", "Parker Brass Ball Valve XV520P XV520P-48:1")) = "Dark Green"
Component.Color(MakePath("Tube & Pipe Runs", "NEW LINES:1", "4 inch s31 with haz loc s70:2")) = "Dark Green"
Component.Color(MakePath("Tube & Pipe Runs", "720A-SPOOL-002:1", "3 inch s31 with haz loc s70:1")) = "Red"
Component.Color(MakePath("Tube & Pipe Runs", "720A-SPOOL-003:1", "3 inch s31 with haz loc s70:1")) = "Red"
Component.Color(MakePath("Tube & Pipe Runs", "720A-SPOOL-003:1", "4 inch s31 with haz loc s70:1")) = "Red"

End If


When I run the code I get the following error:

Error on line 2 in rule: CYCLE CONTROLLER, in document: 720A-TOP ASSEMBLY.iam

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

I do not get the error if i remove the MakePath expression from each line and only reference a subassembly or part inside the top assembly. Only when referencing a part or subassembly inside a subassembly (which requires the MakePath expression) do I get the error.




 

0 Likes
Accepted solutions (1)
573 Views
9 Replies
Replies (9)
Message 2 of 10

CGBenner
Community Manager
Community Manager

@benjaminPXQW3 

Hello & welcome!  I've moved your post here so that the programming experts can take a look at it and hopefully offer some advice.  Good luck!

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 3 of 10

WCrihfield
Mentor
Mentor

Hi @benjaminPXQW3.  What does "Tube & Pipe Runs" represent in those lines of code.  Is that the exact name of an assembly component that represents a sub assembly in the top level of your main assembly?  If not, then that part will likely need to be changed.  You do not include the name of the main assembly itself in this MakePath tool.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 10

benjaminPXQW3
Explorer
Explorer

Thank you! I only saw the main forum section so I posted there.

Message 5 of 10

Curtis_Waguespack
Consultant
Consultant

@benjaminPXQW3 

 

A quick tip on this: You can extract the MakePath syntax by using the Model tree in the rule editor, and right clicking on the target component, and then choosing Capture Current State.

 

Note the curly brackets are a shortcut for assembly the array syntax that we do using the MakePath function.

 

So the following 3 examples do the same thing:

 

Component.IsActive({"Test Assembl:1", "cw_Block2:1"}) = True

 

myComponent = MakePath({"Test Assembl:1", "cw_Block2:1"})
Component.IsActive(myComponent) = True

 

myComponent = MakePath("Test Assembl:1", "cw_Block2:1")
Component.IsActive(myComponent) = True

 

Likewise the following 2 examples do the same thing also:

 

Component.Color({"Test Assembl:1", "cw_Block2:1"}) = "Red"

 

myComponent = MakePath({"Test Assembl:1", "cw_Block2:1"})
Component.Color(myComponent) = "Red"

 

Curtis_Waguespack_0-1717681267927.png

 

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

 

EESignature

Message 6 of 10

benjaminPXQW3
Explorer
Explorer

"Tube & Pipe Runs" refers to the parent tube and pipe assembly within the main/top assembly. That is exactly how iLogic references it when you right-click a part/subassembly and choose "capture current state".

 

It is also how it appears in the browser (see attachment).

Message 7 of 10

Curtis_Waguespack
Consultant
Consultant

@benjaminPXQW3 

 

This worked for me and ran with no error. Note the View Rep needed to reference Master even though it was called Primary in the model.

 

 

Component.Color({"Tube & Pipe Runs", "Run 01" }) = “Red”
Component.InventorComponentInThisContext("Tube & Pipe Runs").SetDesignViewRepresentation("Master")
InventorVb.DocumentUpdate()

 

 

Curtis_Waguespack_2-1717703497888.png

 

 

EESignature

0 Likes
Message 8 of 10

Curtis_Waguespack
Consultant
Consultant

I was able to use this to set the elbow color from the top level assembly as shown. This assumes that "Red" is an appearance in the assembly document already.

 

Dim oAsset As Asset 
oAsset = ThisAssembly.GetAppearanceAsset(assetName := "Red").Asset

Component.InventorComponentInThisContext _
("ASME B16.11 90 Deg Elbow Threaded - Class 3000 1/2:1").Appearance = oAsset

 

Curtis_Waguespack_1-1717703399230.png

 

 

EESignature

Message 9 of 10

benjaminPXQW3
Explorer
Explorer

What if I am trying to change the color of multiple occurrences of the same part across different subassemblies (there are several valves across several runs)? 

Since a given part in a subassembly is assigned an occurrence of 1, 2, 3, etc., would repeated occurrences across different subassemblies (runs in by case) cause an issue? 

0 Likes
Message 10 of 10

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @benjaminPXQW3 ,
If I understand correctly, I think something like this would work.

Dim oAsset As Asset 

oAsset = ThisAssembly.GetAppearanceAsset(assetName := "Red").Asset
Component.InventorComponentInThisContext _
({"Tube & Pipe Runs", "Run 01", "ASME B16.11 90 Deg Elbow Threaded - Class 3000 1/2:1"}).Appearance = oAsset

oAsset = ThisAssembly.GetAppearanceAsset(assetName := "Blue").Asset
Component.InventorComponentInThisContext _
({"Tube & Pipe Runs", "Run 02", "ASME B16.11 90 Deg Elbow Threaded - Class 3000 1/2:1"}).Appearance = oAsset

 

Curtis_Waguespack_0-1717710891558.png

 

 

EESignature