Units passed to Draft.makeRectangle

Need help, or want to share a macro? Post here!
elsordo
Posts: 9
Joined: Sat Jan 30, 2016 6:34 am

Units passed to Draft.makeRectangle

Postby elsordo » Mon Mar 20, 2017 3:17 pm

I have a question regarding units. I created a new document and set the "units" preference to "US customary (in/lb).

I then switched to the ARCH workbench and then created a rectangle. I set the length to 30 ft and the height to 20 ft.

In the python console following python code sequence appeared in the python console.

Code: Select all

pl = FreeCAD.Placement()
pl.Rotation.Q = (0.0,-0.0,-0.0,1.0)
pl.Base = FreeCAD.Vector(0.0,0.0,0.0)
Draft.makeRectangle(length=9144.0,height=6096.0,placement=pl,face=False,support=None)


My question is "What is the relationship between the number 9144 and the number "30 ft". I presume that 9144 is the internal representation of 30 feet but I cannot figure out the transformation formula.

Can someone explain the computation and which python modules handle the functionality?

-David
ickby
Posts: 2431
Joined: Wed Oct 05, 2011 7:36 am

Re: Units passed to Draft.makeRectangle

Postby ickby » Mon Mar 20, 2017 3:29 pm

1 Feet = 304,8 Millimeter
elsordo
Posts: 9
Joined: Sat Jan 30, 2016 6:34 am

Re: Units passed to Draft.makeRectangle

Postby elsordo » Mon Mar 20, 2017 4:05 pm

So the underlying unit of measure is millimeters. Which class/module handles the conversion between units. I would like to re-use the unit conversion code instead of re-inventing the wheel.

I am writing some python scripts to help me design a house using US building technology and as a result I have to work in inches and feet.

-David
DeepSOIC
Posts: 4507
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Units passed to Draft.makeRectangle

Postby DeepSOIC » Mon Mar 20, 2017 7:06 pm

Hi!

Code: Select all

>>> mm = App.Units.MilliMetre
>>> ft = App.Units.Foot
>>> (3.0*ft).getValueAs(mm)
914.4
>>> import Draft
>>> Draft.makeRectangle(2*ft, 3*ft)
created object
<Part::Part2DObject>
>>>

Enjoy!
elsordo
Posts: 9
Joined: Sat Jan 30, 2016 6:34 am

Re: Units passed to Draft.makeRectangle

Postby elsordo » Mon Mar 20, 2017 8:46 pm

Thank you!