Macro for BIM simulation of work

Need help, or want to share a macro? Post here!
User avatar
bernd
Posts: 8443
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Macro for BIM simulation of work

Postby bernd » Mon Nov 21, 2016 5:11 pm

You do not need the animation wb for a first implementation because nothing is moving. You just need to use the python time module for the breaks, change transparency of the object and change visibility of the object in the regard of your new date property. The most cumbersome is to generate the input for this. Since every object needs a date. This could be a thousand or more dates. If such information could be imported it would be cool.

@Yorik and other developer:
Do we have a property which represents a time in words a date and or a time? Would be cool to have such property type for the stuff walpa would like to do. AFAIK we do not have such property type.
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Mon Nov 21, 2016 5:26 pm

bernd wrote: How about if you make your own gant chart and how about importing gant charts from MS project.
Making the Gantt itself will be required for visualization inside the FRC (if it is to plagiarize the Naviswork interface), but to do the planning, in my opinion, at the moment, it is best to keep both softs integrated. In the future, who knows ...

At the moment I do not have MS Project installed on my computer, but I know that it exports in CSV (and it's how NAVISWORK imports the data).
After xml, I'll do csv
bernd wrote: how about projectlibre? Do you use it in daily buissness...Is it comparable like LibreOffice writer with word and calc with excel?
Yes, but with a little less resources, but very "usable".
User avatar
saso
Posts: 1333
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Macro for BIM simulation of work

Postby saso » Mon Nov 21, 2016 5:36 pm

Having our own gant chart in FC would for sure be the best... And some day we will 8-)

As for the animation WB, I was thinking if not using it, maybe at least some of its code can be reused, also exploded assembly animation viewtopic.php?t=9028 has elements that are close to this, but yes it all depends how far one wishes to animate this, it can also be done in a much more simple way, just change transparency and visibility of objects as suggested by bernd.
User avatar
saso
Posts: 1333
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Macro for BIM simulation of work

Postby saso » Mon Nov 21, 2016 5:57 pm

bernd wrote:@Yorik and other developer:
Do we have a property which represents a time in words a date and or a time? Would be cool to have such property type for the stuff walpa would like to do. AFAIK we do not have such property type.
First thing to check would IMO be to check if maybe IFC has support for this?
User avatar
microelly2
Posts: 4415
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Macro for BIM simulation of work

Postby microelly2 » Mon Nov 21, 2016 7:12 pm

Most things in the video can be done with the Explosion Animation WB, there is only one detail - the growing columns which is not supported.
So you have to assemble your parts and define the ways the componentes flow in.

However if you want more comfort
multi camera view, growing objects, text information inside please request for details here,
it's an interesting task to combine an assembly process with an schedule.

Would be nice to get an animation tool for interactive visualization of such a process.
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Wed Nov 23, 2016 12:54 pm

microelly2 wrote:Most things in the video can be done with the Explosion Animation WB, ...
I need a tutorial, can not learn alone how to use this WB.
User avatar
microelly2
Posts: 4415
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Macro for BIM simulation of work

Postby microelly2 » Wed Nov 23, 2016 1:33 pm

walpa wrote:
microelly2 wrote:Most things in the video can be done with the Explosion Animation WB, ...
I need a tutorial, can not learn alone how to use this WB.
https://www.youtube.com/watch?v=t1jESJO2am4&t=312s
https://www.youtube.com/watch?v=5FGVNQLp1sA
https://www.youtube.com/watch?v=GB6lTOFM2p4
https://www.youtube.com/watch?v=aZaUjQURT04
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Wed Nov 23, 2016 2:10 pm

Another problem:

Testing a piece of code and giving different results in IDLE Python and FRC console. Maybe Python version difference?

Code to paste on console:

Code: Select all

import xml.etree.ElementTree as ET
from datetime import datetime,  date
from PySide import QtCore, QtGui

class PlannerData:
    def __init__(self, file):
        self.file = file
        self.taskData = {}
        self.startDate = None
        self.finishDate = None
        self.projPeriod = None
        self.seqDays = []
        self.percentConclTask = None

    def getXmlData(self): 
        "gets data in the document ProjectLibre xml"
        tree = ET.parse(self.file)
        root = tree.getroot()
        
        #gets data of the tasks 
        task = root.findall("{http://schemas.microsoft.com/project}Tasks")
        for parent in task:
            for child in parent:
                a=[]
                uid = child.findtext("{http://schemas.microsoft.com/project}UID")
                name = child.findtext("{http://schemas.microsoft.com/project}Name")
                start = child.findtext("{http://schemas.microsoft.com/project}Start")
                start = datetime.strptime(start, '%Y-%m-%dT%H:%M:%S').date()
                finish = child.findtext("{http://schemas.microsoft.com/project}Finish")
                finish = datetime.strptime(finish, '%Y-%m-%dT%H:%M:%S').date()
                
                period = finish-start
                period = period.days
                
                #list of data of task
                a.append(uid)
                a.append(name)
                a.append(start)
                a.append(finish)
                a.append(period)
                self.taskData[uid] = a
    
        
        #gets data of the project period
        start2 = root.findtext("{http://schemas.microsoft.com/project}StartDate")
        self.startDate = datetime.strptime(start2, '%Y-%m-%dT%H:%M:%S').date()
        finish2 = root.findtext("{http://schemas.microsoft.com/project}FinishDate")
        self.finishDate = datetime.strptime(finish2, '%Y-%m-%dT%H:%M:%S').date()
        
        period = self.finishDate - self.startDate
        self.projPeriod = period.days
        
        #gets the sequence of days between the start and end date of the project for use in Simulation
        dat = self.startDate
        while dat <= self.finishDate:
            self.seqDays.append(dat)
            dat = date.toordinal(dat)+1
            dat = date.fromordinal(dat)
        
        return    self.taskData#, self.startDate, self.finishDate#,  self.projPeriod, self.seqDays
        
    def getCsvData(self): 
        "gets data in the document Csv"
        pass
        
   
    def calcPercentConclTask(self, task,  dat):
        "calculation of the percentage of completion of the task for use in the visualization of the Simulation"
        tasks = self.taskData
        start = tasks[task][2]
        finish = tasks[task][3]
        totalDays = tasks[task][4]
        
        if dat < start:
            self.percentConclTask = 100
        elif dat > finish:
            self.percentConclTask = 0
        else:
            concl = dat-start
            concl= concl.days
            self.percentConclTask = int((1-(concl / totalDays))*100)
        
        return self.percentConclTask

def execute(): 
    #for teste in FreeCad
    filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open file','*.xml')
    file =filename[0]
    
    #for test in IDLE Python, copy file to the same directory
    #file  = 'teste1.xml'
    
    teste='2016-11-28T08:00:00'
    dat = datetime.strptime(teste, '%Y-%m-%dT%H:%M:%S').date()
    print (dat)
    
    plan = PlannerData(str(file))
    i = plan.getXmlData()
    print (i)
    for o in i:
        p= plan.calcPercentConclTask( o,  dat)
        print ("id:%s  transparency: %d" %(o, p ))

execute()
ProjectLibre interface, expected Result (IDLE) and xml file to test:
Attachments
project.JPG
project.JPG (107.75 KiB) Viewed 1620 times
Captura.JPG
Captura.JPG (50.39 KiB) Viewed 1620 times
teste1.zip
(3.04 KiB) Downloaded 20 times
User avatar
yorik
Site Admin
Posts: 11567
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Macro for BIM simulation of work

Postby yorik » Wed Nov 23, 2016 11:38 pm

bernd wrote:@Yorik and other developer: Do we have a property which represents a time in words a date and or a time? Would be cool to have such property type for the stuff walpa would like to do. AFAIK we do not have such property type.
Yes that's a good idea... The thing is how to do that the clever way. There are a lot of standards to represent time ( https://en.wikipedia.org/wiki/Timestamp ) but a simple integer can be used to store a time stamp.

also, we might need something different than just timestamps, more like time spans. So this could evolve into something bigger, where your objects "belong" to a certain phase, etc...

Maybe the construction phase needs to be like a material? An external object?
saso wrote:First thing to check would IMO be to check if maybe IFC has support for this?
I think it has, don't remember exactly what, but I've seen something about construction phases in the docs.

In any case this all goes into the same direction: We should look at what/how others do and build a plan...
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Macro for BIM simulation of work

Postby chakkree » Thu Nov 24, 2016 9:41 am

Your code can run with python 2.7
But change line 102 to
Msg ("id:%s transparency: %d\n" %(o, p ))
reslut will show on "Report view"
TestRunReadOpenProj.png
TestRunReadOpenProj.png (176.35 KiB) Viewed 1577 times
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8975 (Git)
Build type: Release
Branch: master
Hash: 3e06d0a09077ea0e719ae1970cfbe6426ea87fa1
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0