Macro for BIM simulation of work

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
walpa
Posts: 65
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Macro for BIM simulation of work

Post by walpa »

Hello everybody!
First, congratulations on the beautiful work of developing this sensational tool.
I'm a civil engineer and I'm starting to learn FreeCAD.
English is not my native language, so I apologize for the translation.
I have great interest in BIM tools, and since FreeCAD is an open and developing tool, I would like to contribute a bit.
I noticed that the FRC still does not have a tool similar to Autodesk's Naviswork, so I'm trying (with what little I know of python) to create a macro that simulates the progress of a work, changing the view of the objects in the FRC according to a Gantt chart.
It's just a start ...
In the post viewtopic.php?t=15865 the basis for the development of the Gantt chart was launched, but I believe that this should not be the focus of the FRC, since there are already many tools in the market for this purpose and professionals (at least in the market where they work) will prefer Continue to use these known softs.

The idea is to use the data in the xml file generated by the software LIBREPROJECT (alternative opensource to MSProject), create link with the ARCH objects and change the transparency of the objects according to the sequence of dates of the work.


Help me please:

1 - xml file data is read and generate a list dictionary where the data of each Gantt task is stored.
2- to make the connection of the xml data with the FRC objects:

Code: Select all

obj = FreeCAD.ActiveDocument.Objects
for o in obj:
    if hasattr(o,"Proxy"):
        o.addProperty("App::PropertyList","taskData","Tasks","Task data list")
    # property list with the data of each Gantt task
 
Here I am having problems, because I create this property but I can not access to include or use the data.

For example:

Code: Select all

c = FreeCAD.ActiveDocument.getObjectsByLabel('Wall')
c.taskData = [1,2,3]
   
Error: Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'taskData'

In the post viewtopic.php?f=23&t=5197&p=41118&hilit ... ion#p41118 Yorik gave an example of use but is not working.

Any help will be appreciated!

Tanks!

OS: Windows 7
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6704 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Hash: 0c449d7e8f9b2b1fb93e3f8d1865e2f59d7ed253
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
User avatar
wandererfan
Veteran
Posts: 6325
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Macro for BIM simulation of work

Post by wandererfan »

walpa wrote:

Code: Select all

c = FreeCAD.ActiveDocument.getObjectsByLabel('Wall')
c.taskData = [1,2,3]
   
Error: Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'taskData'
caveat: I have no knowledge of BIM, FRC and only a little familiarity with Arch, but this might help

Code: Select all

listOfDocumentObjects = FreeCAD.ActiveDocument.getObjectsByLabel('Wall')  
interestingDocumentObject = listOfDocumentObjects[0]
interestingDocumentObject.taskData = [1,2,3]
wf
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Macro for BIM simulation of work

Post by bernd »

May be a short description:
a label in FreeCAD is not unique. Lots of object could be labeled "Wall". Thus getObjectsByLabel('Wall') does not return an object it returns a list of all objects labeled "Wall" The first object of the list is accessed by [0]

Code: Select all

c = FreeCAD.ActiveDocument.getObjectsByLabel('Wall')[0]
c.taskData = [1,2,3]
should work.

if you would like to access an object by its uniqe name you could

Code: Select all

c = App.ActiveDocument.getObject('Box')
or

Code: Select all

App.ActiveDocument.Box
BTW: I'm really really curious about what you would like to do ! I'm structural engineer dedicated to any kind of BIM tools.
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Macro for BIM simulation of work

Post by yorik »

If I'm not mistaken, "App::PropertyList" doesn't exist. You need PropertyStingList or PropertyFloatList or PropertyIntegerList. Probably FreeCAD just fails silently when you use a non-existing class name, and your property was not created.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Macro for BIM simulation of work

Post by bernd »

yorik wrote:If I'm not mistaken, "App::PropertyList" doesn't exist. You need PropertyStingList or PropertyFloatList or PropertyIntegerList. Probably FreeCAD just fails silently when you use a non-existing class name, and your property was not created.
You are right Yorik.
make a new document

Code: Select all

import Arch
Arch.makeWall([],5000,250,2500)
for p in sorted(App.ActiveDocument.getObject("Wall").supportedProperties()):
    print p

Code: Select all

>>> import Arch
>>> Arch.makeWall([],5000,250,2500)
<Part::PartFeature>
>>> for p in sorted(App.ActiveDocument.getObject("Wall").supportedProperties()):
...     print p
... 
App::PropertyAcceleration
App::PropertyAngle
App::PropertyArea
App::PropertyBool
App::PropertyBoolList
App::PropertyColor
App::PropertyColorList
App::PropertyDistance
App::PropertyEnumeration
App::PropertyExpressionEngine
App::PropertyFile
App::PropertyFileIncluded
App::PropertyFloat
App::PropertyFloatConstraint
App::PropertyFloatList
App::PropertyFont
App::PropertyForce
App::PropertyInteger
App::PropertyIntegerConstraint
App::PropertyIntegerList
App::PropertyIntegerSet
App::PropertyLength
App::PropertyLink
App::PropertyLinkList
App::PropertyLinkSub
App::PropertyLinkSubList
App::PropertyMap
App::PropertyMaterial
App::PropertyMaterialList
App::PropertyMatrix
App::PropertyPath
App::PropertyPercent
App::PropertyPlacement
App::PropertyPlacementLink
App::PropertyPressure
App::PropertyPythonObject
App::PropertyQuantity
App::PropertyQuantityConstraint
App::PropertySpeed
App::PropertyString
App::PropertyStringList
App::PropertyUUID
App::PropertyVector
App::PropertyVectorDistance
App::PropertyVectorList
App::PropertyVolume
Fem::PropertyFemMesh
Fem::PropertyPostDataObject
Part::PropertyFilletEdges
Part::PropertyGeometryList
Part::PropertyPartShape
Part::PropertyShapeHistory
>>> 
walpa
Posts: 65
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Post by walpa »

Excuse me, copy / paste wrong code (my wife distracted me ...) :oops:

Thank you all for the quick response. Now I understand how it works:

Code: Select all

obj = FreeCAD.ActiveDocument.Objects
for o in obj:
    if hasattr(o,"Proxy"):
        o.addProperty("App::PropertyStringList","taskData","Tasks","Task data list")

# LIBREPROJECT activity data (id, name, start data, finish date, quant days)
taskDataID = ['1', 'Foundation', '2016-10-31T08:00:00', '2016-11-11T17:00:00', '11']

f = FreeCAD.ActiveDocument.getObjectsByLabel('Foundation')[0]  
f.taskData = taskDataID
walpa
Posts: 65
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Post by walpa »

bernd wrote: BTW: I'm really really curious about what you would like to do ! I'm structural engineer dedicated to any kind of BIM tools.
When I finish the first step:

PROJECTLIBRE >> xml >> transparency of FRC objects according to dates

Put the script to test.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Macro for BIM simulation of work

Post by saso »

If I correctly understand what you want to do ( https://www.youtube.com/watch?v=tQkDRXo7tLM, https://www.youtube.com/watch?v=sXVuNLgaaOc ?), you might also want to check some of the work that Javier and microelly (sorry if I forgot others :oops: ) did for the animation WB (workbench)... Check around this forum and youtube for more info about it.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Macro for BIM simulation of work

Post by bernd »

offtopic @walpa:
how about projectlibre? Do you use it in daily buissness. How about if you make your own gant chart and how about importing gant charts from MS project. Does it handel complex ones. Is it comparable like LibreOffice writer with word and calc with excel?
walpa
Posts: 65
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Post by walpa »

saso wrote:If I correctly understand what you want to do ( https://www.youtube.com/watch?v=tQkDRXo7tLM, https://www.youtube.com/watch?v=sXVuNLgaaOc ?), you might also want to check some of the work that Javier and microelly (sorry if I forgot others :oops: ) did for the animation WB (workbench)... Check around this forum and youtube for more info about it.
Yes, that's the idea.
I need a tutorial for WB animation.
I can not understand yet how to work with this wb, but after we integrate the planning soft with FRC, surely this wb will be very important to generate more professional animations.
Post Reply