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: 

Get environment variable to run external iLogic rule

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1143 Views, 3 Replies

Get environment variable to run external iLogic rule

Hi all,

I tried to read an environment with iLogic and to combine it with an external rule name and to pass the whole path over to iLogicVB.RunExternalRule.

StrPath = Environment.GetEnvironmentVariable("ILOGIC_DIR")
ilogic_rule = "IPT__01_New_Document_EXT.iLogicVb"

rule = StrPath & ilogic_rule

'MessageBox.Show(rule, "iLogic Rule to execute")

iLogicVb.RunExternalRule(rule)

 The message box shows the correct path, but I allways receive a error massage:
ddd.jpg
'GetEnvironmentVariable' is not a member of 'Inventor.Environment'


How to resolve this problem?
Any help would be appreciated.
Thanks in advance,

Raphael

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Hi all again,

does iLogicVb.RunExternalRule("rule name") not accept variables?

Can anyone help me?
Thanks!

Raphael

Message 3 of 4
Anonymous
in reply to: Anonymous

Hi Raphael,

you need two items solved:

1) Inventor.Environment covers the UI; you need to call the system.environment explicitly

2) The variable needs to set for the current process

Find the rule code that works:

Dim StrPath As String = Nothing

System.Environment.SetEnvironmentVariable("iLogic_DIR", "C:\Temp")

 

StrPath = System.Environment.GetEnvironmentVariable("iLogic_DIR")

 

ilogic_rule = "Test_Rule.iLogicVb"

 

rule = StrPath & "\" &  ilogic_rule

 

MessageBox.Show(rule, "iLogic Rule to execute")

 

iLogicVb.RunExternalRule(rule)

 

BTW: iLogic.Automation 2013 allows to set the directory as Inventor iLogic.Automation option; you don't longer need to use environment variables 🙂

 

Hope this helps,

Markus

Message 4 of 4
Anonymous
in reply to: Anonymous

Hi Markus,

 

thanks for your fast reply, I really appreciate your help.
I added the variable target because I want to get a user variable (found that in an other forum):


StrPath = System.Environment.GetEnvironmentVariable("name variable", EnvironmentVariableTarget.User)

Great, now my rule works as expected.
I am not familiar with iLogic.Automation 2013, because we are still on Inventor 2011.
The reason for calling a system/user environment is that we have a simple batch tool in use which sets the correct settings for our CAD systems (Inventor and Solid Edge) and SAP, CADENAS PARTsolutions and so on. At the end of the routine Inventor is launched.

Thanks

Raphael

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

Post to forums  

Autodesk Design & Make Report