Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KiCAD 6 variables not supported #159

Open
fromsawa opened this issue Jan 20, 2023 · 1 comment
Open

KiCAD 6 variables not supported #159

fromsawa opened this issue Jan 20, 2023 · 1 comment

Comments

@fromsawa
Copy link

When importing a KiCAD v6 PCB, models usually contain ${KICAD6_3DMODEL_DIR} (and in my case ${KICAD_USER_3DMODEL_DIR}).

I suggest the following change (so that ${ENV} is generally expanded by environment variables):

diff --git a/kicadStepUptools.py b/kicadStepUptools.py
index e1ec7cc..92fc86b 100644
--- a/kicadStepUptools.py
+++ b/kicadStepUptools.py
@@ -4424,7 +4424,12 @@ def Load_models(pcbThickness,modules):
             say('adjusting Local Path')
             say('step-module-replaced '+step_module)
         elif (step_module.find('${')!=-1) and encoded==0:  #extra local ${ENV} 3D path
-            step_module= re.sub('\${.*?}/', '', step_module)
+            match = re.search(u'\${([^}]+)}(.*)', step_module)
+            if match:
+                envvar=match.group(1)
+                step_module=os.getenv(envvar, envvar)+match.group(2)
+            else:
+                step_module= re.sub('\${.*?}/', '', step_module)
             #step_module=step_module.decode("utf-8").replace(u'${}/', u'')
             step_module=step_module.replace(u'${}/', u'')
             step_module=step_module.replace(u'"', u'')  # name with spaces
@easyw
Copy link
Owner

easyw commented Jan 21, 2023

@fromsawa
kicad environment variables are not available in FreeCAD through python...
There is a FC preference page in which you can preset up to 4 different 3D model searching paths

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants