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
mceitrs
1124 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

Inventor Professional 2011
Windows 7 Enterprise 64bit
Dell Precision M4500
Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
8 GB RAM
3 REPLIES 3
Message 2 of 4
mceitrs
in reply to: mceitrs

Hi all again,

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

Can anyone help me?
Thanks!

Raphael

Inventor Professional 2011
Windows 7 Enterprise 64bit
Dell Precision M4500
Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
8 GB RAM
Message 3 of 4
mkoechl
in reply to: mceitrs

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
mceitrs
in reply to: mkoechl

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

Inventor Professional 2011
Windows 7 Enterprise 64bit
Dell Precision M4500
Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
8 GB RAM

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

Post to forums  

Autodesk Design & Make Report