KeithSloan / GDML

FreeCAD GDML Workbench - AddonManager Installable
Other
50 stars 17 forks source link

position ref #22

Closed lambdam94 closed 3 years ago

lambdam94 commented 4 years ago

Hello Keith

in position definition

and

and

should give the same thing.

But only, unit="mm" gives the good position. It seems that unit is not taken into account. Freecad IHM shows only 2 numbers after comma, so "0.000075mm" appears "0.00mm" (even if 000075mm is writen in the file).

Could you take a look? Thanks!

Regards Dam

KeithSloan commented 4 years ago

Not understanding - please could you clarify

in position definition

and

and

should give the same thing.

KeithSloan commented 4 years ago

Is the issue any object with a non default position is not exported correctly unless units = mm?

KeithSloan commented 4 years ago

Have tried changing the position of a GDMLBox via FreeCAD preferences and even if I enter 1M it changes to 1000mm. How are you changing position to get a non mm value.

lambdam94 commented 4 years ago

Hello Keith

sorry about the bad message, the preview is a good option...

It will be better with some exemples. It is a small box in a world with a delta z =5um. If we write a "delta z =5e-6 m", the delta z is considered equal to 0.

exempleDelta5um is ok exempleDelta5e-6m is nok

exempleDelta5um.gdml.txt exempleDelta5e-6m.gdml.txt

In exempleDelta5e-6m.gdml, it seems that "m" is considered "mm".

Regards Dam

KeithSloan commented 4 years ago

Just come across this which may or may not be relevant - Anyway posting link here just in case https://forum.freecadweb.org/viewtopic.php?f=10&t=48451

lambdam94 commented 4 years ago

Hello Keith,

Your link seems to be a good solution in order to manage the different types of length.

I found the solution of this issue in def getMult(fp) in GDMLShared. Here 'unit' in fp.attrib is not well read. hasattr(fp,'unit') and unit = fp.unit don't give the same thing.

If you add these 2 lines (on lines147), it seems working elif 'unit' in fp.attrib : unit = fp.attrib['unit'] elif 'lunit' in fp.attrib : unit = fp.attrib['lunit']

cf. a solution: getMult.txt

Could you please add this to main code? Thanks!

Regards Dam

KeithSloan commented 4 years ago

Have updated - hopefully now okay.

lambdam94 commented 4 years ago

Yes, It is ok. Thanks!

Regards Dam

KeithSloan commented 4 years ago

Tried importing lhcbvelo.gdml and these changes cause errors with Polycone

str object has no attribute attrib

GDMLShared.py line 147

KeithSloan commented 4 years ago

Code changed to

if hasattr(fp,'lunit') : trace('lunit : '+fp.lunit) unit = fp.lunit elif hasattr(fp,'unit') : trace('unit : '+fp.unit) unit = fp.unit elif hasattr(fp,'attrib') : if 'unit' in fp.attrib : unit = fp.attrib['unit'] elif 'lunit' in fp.attrib : unit = fp.attrib['lunit'] else : return 1

lambdam94 commented 4 years ago

With the hasattr(fp,'attrib') test, it seems like before! Regards Dam

KeithSloan commented 4 years ago

"With the hasattr(fp,'attrib') test, it seems like before!"

Like before?

It behaves like before your code is added ? i.e. fixes nothing.

lambdam94 commented 3 years ago

Fix in the today version.