Macro for BIM simulation of work

Need help, or want to share a macro? Post here!
User avatar
microelly2
Posts: 4410
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Macro for BIM simulation of work

Postby microelly2 » Thu Nov 24, 2016 10:20 am

I see a first real application of cascaded Animation managers: Every activity can be mapped to a manager which controls some animation nodes
what still is needed: create a DAG with managers from the project database.
once more a 2d node editor like pse ore sverchok makes sense.
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Thu Nov 24, 2016 11:59 am

chakkree wrote:Your code can run with python 2.7
But change line 102 to
Msg ("id:%s transparency: %d\n" %(o, p ))
Thanks for the sugestion.
What I am not understanding are the different results for the value of transparency.
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Thu Nov 24, 2016 1:20 pm

yorik wrote: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...
I'm a beginner ... getting lost and learning ...

I think the gantt.py (viewtopic.php?t=15865) code could be used as the basis for a built-in FRC planner. datetime.date was used, but if another type is better, I accept guidance.
saso wrote:First thing to check would IMO be to check if maybe IFC has support for this?
yorik wrote:I think it has, don't remember exactly what, but I've seen something about construction phases in the docs.
I do not even know where to start ... :)
yorik wrote:In any case this all goes into the same direction: We should look at what/how others do and build a plan...
But I think:

First stage (I'm developing):
Create object with file information: path, name, ...
Create sub-objects with task information
Linking obj FRC (property) to tasks
Do basic animation (transparency)
To appear in the FRC interface

Second stage:
Cascaded Animation managers (microelly2 help us)

Third stage:
(gantt.py)
Create interface to view the gantt in FRC
Create interface to manipulate gantt data, and export file

Fourth stage:
a dream...
Artificial intelligence: collision of objects, critical path of the work, cost as a function of time ...
yorik wrote:Maybe the construction phase needs to be like a material? An external object?
I think external object can give more freedom to designer linking obj FRC to tasks you want, but I still do not know FRC like you guys to say that.
Is it possible to create a property for objectgroup? It would be a way to create construction phase.
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 1:53 pm

I think int/int = 0
casting integer variable to float.
change to
self.percentConclTask = int((1-( float(concl) / totalDays))*100)

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"
        #Msg(self.taskData); Msg('\n\n')
        tasks = self.taskData
        start = tasks[task][2]
        finish = tasks[task][3]
        totalDays = tasks[task][4]
        """Msg(task); Msg(' ')
        Msg(dat ); Msg(' ')
        Msg(start); Msg(' ')
        Msg(finish);  Msg('\n')
        Msg(dat < start);Msg(dat > finish); Msg(' ')"""
        if dat < start:
            self.percentConclTask = 100
        elif dat > finish:
            self.percentConclTask = 0
        else:
            concl = dat-start
            concl= concl.days
            self.percentConclTask = int((1-( float(concl) / totalDays))*100)
        #Msg('%g\n'%self.percentConclTask)
        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()
    Msg (dat); Msg('\n')
    
    plan = PlannerData(str(file))
    i = plan.getXmlData()
    Msg (i); Msg('\n')
    for o in i:
        start=i[o][2]
        finish=i[o][3]
        totalDays=i[o][4]
        p= plan.calcPercentConclTask( o,  dat)
        Msg ("id:%s %s transparency: %d\n" %(o, i[o][1], p ))

execute()
TestRunReadOpenProj2.png
TestRunReadOpenProj2.png (184.43 KiB) Viewed 1276 times
User avatar
saso
Posts: 1332
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Macro for BIM simulation of work

Postby saso » Thu Nov 24, 2016 2:21 pm

As I understand the problems is that the transparency values should be 0 (fully visible, as construction finished), 50, 100, 100, 100 (invisible, as construction not yet started) and not 0, 22, 28, 100, 100 ?
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Fri Nov 25, 2016 11:38 am

@ chakkree

Thank you, problem solved.

saso wrote:As I understand the problems is that the transparency values should be 0 (fully visible, as construction finished), 50, 100, 100, 100 (invisible, as construction not yet started) and not 0, 22, 28, 100, 100 ?
All objects start with 100 (invisible), and the transparency value decreases in proportion to the date's progress until they are visible.
User avatar
saso
Posts: 1332
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Macro for BIM simulation of work

Postby saso » Fri Nov 25, 2016 3:42 pm

walpa wrote:
saso wrote:As I understand the problems is that the transparency values should be 0 (fully visible, as construction finished), 50, 100, 100, 100 (invisible, as construction not yet started) and not 0, 22, 28, 100, 100 ?
All objects start with 100 (invisible), and the transparency value decreases in proportion to the date's progress until they are visible.
Yes, I understood wrongly what the problem with your code was...
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Thu Dec 01, 2016 10:07 pm

I ask for help again.
I was able to make a macro that worked as I wanted it :D
So I ventured to develop a workbench to make life easier ...
It is working until the initialization of a GUI for the user to search the data source file (XML), then it gives error:
"Gui :: Command :: activated (0): Unknown C ++ exception thrown"
frc erro.jpg
frc erro.jpg (70.69 KiB) Viewed 1199 times
Probably some stupidity from line 55 of the Planner.py file.
Any idea?
Thanks.
Walmir

Follow the files ...
Attachments
Project_test.FCStd
(38.28 KiB) Downloaded 29 times
Planner.zip
(18.25 KiB) Downloaded 23 times
Project_test.zip
(3.05 KiB) Downloaded 29 times
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Tue Dec 06, 2016 6:38 pm

Problem solved.
The import QTdesigner UI file was the error.
walpa
Posts: 22
Joined: Wed Nov 09, 2016 5:22 pm
Location: Brazil

Re: Macro for BIM simulation of work

Postby walpa » Tue Dec 06, 2016 8:00 pm

Available the first prototype of the workbench planner, for anyone who has an interest in testing.

Tutorial:
- creating objects on Arch workbench
- access Planner workbench
view12.jpg
view12.jpg (222.37 KiB) Viewed 1168 times
- click to Create Planner
- search xml file
- click import data and close
view34.jpg
view34.jpg (206.1 KiB) Viewed 1168 times
view56.jpg
view56.jpg (227.96 KiB) Viewed 1168 times
- on each Arch object, set the Planner_ID property, linking to the activity
- select the Planner group and click Create Simulation
view78.jpg
view78.jpg (206.1 KiB) Viewed 1168 times
The result (in my opinion) still does not have a good effect, but it is only a first experience. If a more complex animation is applied, it can be interesting.

I expect criticism and suggestions.

Thanks.
Walmir

Ps - sorry for the screens in portuguese
Attachments
Planner.zip
(18.93 KiB) Downloaded 39 times