Arch survey and code

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
flokart
Posts: 21
Joined: Sun Apr 10, 2016 12:15 pm

Arch survey and code

Post by flokart »

I discovered the arch survey tool... another nice feature. On the freecad description page about arch survey is also a python script which should do the same thing..but i get no result ...hope someone can help me out.

here the script from the description page about arch survey.
Image

This is my result with arch survey tool..very nice.
Image
And here the result with the script..the console say only run..but no result.(i tried it also with part objects)
Image

Thanks in advanced...maybe someone knows how does it work.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Arch survey and code

Post by chakkree »

I think if run python macro from a file. It can not use 'print' command, it can use in "Python Console" only.
I'm replaced 'Msg' command to report on "Report View" panel.
The result is shown in a figure below.

Code: Select all

import FreeCADGui

selection = FreeCADGui.Selection.getSelectionEx()
for obj in selection:
    for element in obj.SubObjects:
        Msg('Area:' + str(element.Area) + '\n')
        Msg('Length:' + str(element.Length)  + '\n')
        Msg('Volume:' + str(element.Volume) + '\n' )
        Msg('Center of Mass :' + str(element.CenterOfMass) + '\n' )
        Msg('---------------------------------\n')  
SurveyObject.png
SurveyObject.png (213.38 KiB) Viewed 2033 times
flokart
Posts: 21
Joined: Sun Apr 10, 2016 12:15 pm

Re: Arch survey and code

Post by flokart »

chakkree thanks a lot for your help....I tried the comand also in the python Console but i hit only one time Enter.
With your advice i tried it a second time and hit two times enter to confirm the command and all infos get printed in the Console.

Also a big thanks for your code ..works great. I tried to get also the object NAME or LABEL with the lines in the picture..but as often no luck.

Image

Maybe you can help me again..or someone else.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Arch survey and code

Post by chakkree »

Now, I'm not sure.
I'm got code from this, http://www.freecadweb.org/wiki/index.ph ... rch_Survey
and paste to python console, the result as a figure below.

Code: Select all

import FreeCADGui
selection = FreeCADGui.Selection.getSelectionEx()
for obj in selection:
   for element in obj.SubObjects:
       print "Area: ", element.Area
       print "Length: ", element.Length
       print "Volume: ", element.Volume
       print "Center of Mass: ", element.CenterOfMass
ArchSurvey.png
ArchSurvey.png (240.71 KiB) Viewed 2024 times
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7989 (Git)
Build type: Release
Branch: master
Hash: 8051d32adc646a1580d43a38253fd5eddb3932e6
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Arch survey and code

Post by chakkree »

flokart wrote: I tried to get also the object NAME or LABEL with the lines in the picture..but as often no luck.

Image

Maybe you can help me again..or someone else.
Can this solve for you?

Code: Select all

import FreeCADGui
selection = FreeCADGui.Selection.getSelectionEx()
for obj in selection:
        Msg('Name:' + str(obj.Object.Name) + '\n')

for obj in selection:
        Msg('Label:' + str(obj.Object.Label) + '\n')
ArchSurvey2.png
ArchSurvey2.png (244.71 KiB) Viewed 2020 times
flokart
Posts: 21
Joined: Sun Apr 10, 2016 12:15 pm

Re: Arch survey and code

Post by flokart »

Thanks again ....yep that solved my problem...it works great.

Image
Post Reply