Skip to content

Commit

Permalink
Fix position center
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithSloan committed Aug 25, 2020
1 parent 8c4e188 commit 3e5fc2b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions freecad/gdml/GDMLShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
from math import *
import FreeCAD, Part

from lxml import etree as ET

global define

global printverbose
Expand Down Expand Up @@ -137,7 +139,9 @@ def getRef(ptr, name) :
return wrk

def getMult(fp) :
unit = 'mm' # set default
# Watch for unit and lunit
print('getMult : '+str(fp))
if hasattr(fp,'lunit') :
trace('lunit : '+fp.lunit)
unit = fp.lunit
Expand All @@ -159,7 +163,7 @@ def getMult(fp) :
elif unit == 'dm' : return(100)
elif unit == 'm' : return(1000)
elif unit == 'km' : return(1000000)
print('unit not handled : '+lunit)
print('unit not handled : '+unit)

def getDegrees(flag, r) :
import math
Expand Down Expand Up @@ -229,8 +233,15 @@ def processPlacement(base,rot) :


def getPositionFromAttrib(pos) :
#print(pos.attrib)
print('getPositionFromAttrib')
print('pos : '+str(ET.tostring(pos)))
print(pos.attrib)
#print('pos attrib : '+str(ET.tostring(pos.attrib)))
#if hasattr(pos.attrib, 'unit') : # Note unit NOT lunit
#if hasattr(pos.attrib,'name') :
# name = pos.get('name')
# if name == 'center' :
# return(0,0,0)
mul = getMult(pos)
px = mul * getVal(pos,'x')
py = mul * getVal(pos,'y')
Expand All @@ -253,6 +264,7 @@ def getDefinedPosition(name) :
# get Position from define section
pos = define.find("position[@name='%s']" % name )
if pos != None :
print('Position : '+str(ET.tostring(pos)))
trace(pos.attrib)
return(getPositionFromAttrib(pos))
else :
Expand Down

0 comments on commit 3e5fc2b

Please sign in to comment.