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: 

Setting Pathfile to be user specific in onedrive using ilogic

2 REPLIES 2
Reply
Message 1 of 3
Castro_Jerome
109 Views, 2 Replies

Setting Pathfile to be user specific in onedrive using ilogic

Hi Guys!

 

I need help with setting the path to be username specific for ilogic.

This is the code i have.

 

If DOOR = "2 Pilot Lights" Then
	Component.Replace("DOOR", "C:\Users\JACA\OneDrive\Documents\Vault\Spartech\Power & Drives\LV MCC\FVNR Assemblies\Doors\FVNR_3X1_DOOR_2P_NR.iam", True)

ElseIf DOOR = "3 Pilot Lights" Then
	Component.Replace("DOOR", "C:\Users\JACA\OneDrive\Documents\Vault\Spartech\Power & Drives\LV MCC\FVNR Assemblies\Doors\FVNR_3X1_DOOR_3P.iam", True)

 

JACA is the username and i want to set that to be whatever their login username is. 

Tags (2)
2 REPLIES 2
Message 2 of 3

Try to use user environment variable %OneDrive% or something similar.

See picture below or try it in command line using SET command without arguments

 

MichaelNavara_3-1700637379465.png

 

Command line sample:

 

Microsoft Windows [Version 10.0.22631.2428]
(c) Microsoft Corporation. Všechna práva vyhrazena.

C:\Users\michael.navara>set
... something here ...
OneDrive=C:\Users\michael.navara\OneDrive
... something here ...

 

 

And in iLogic you can use ExpandEnvironmentVariables to get the value

 

Dim oneDriveDir = System.Environment.ExpandEnvironmentVariables("%OneDrive%")
Dim fileName = System.IO.Path.Combine(oneDriveDir, "Documents\Vault\Spartech\Power & Drives\LV MCC\FVNR Assemblies\Doors\FVNR_3X1_DOOR_2P_NR.iam")

logger.Debug(fileName)

 

 

 

 

 

Message 3 of 3
JelteDeJong
in reply to: Castro_Jerome

Assuming that you have set up your project files correctly, then you can also use the information in there. This has the extra advantage that if you ever change your project file the rule will keep working.

try something like this.

Dim doc As AssemblyDocument = ThisDoc.document

Dim project = ThisApplication.DesignProjectManager.ActiveDesignProject
Dim designPath = project.WorkspacePath

Dim lastPartPath = String.Empty
If DOOR = "2 Pilot Lights" Then lastPartPath = "Spartech\Power & Drives\LV MCC\FVNR Assemblies\Doors\FVNR_3X1_DOOR_2P_NR.iam.iam"
If DOOR = "3 Pilot Lights" Then lastPartPath = "Spartech\Power & Drives\LV MCC\FVNR Assemblies\Doors\FVNR_3X1_DOOR_3P.iam"

Dim path = System.IO.Path.Combine(designPath, lastPartPath)

MsgBox(path)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

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

Post to forums  

Autodesk Design & Make Report