Macro for BIM simulation of work
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Macro for BIM simulation of work
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.
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.
Re: Macro for BIM simulation of work
Thanks for the sugestion.chakkree wrote:Your code can run with python 2.7
But change line 102 toMsg ("id:%s transparency: %d\n" %(o, p ))
What I am not understanding are the different results for the value of transparency.
Re: Macro for BIM simulation of work
I'm a beginner ... getting lost and learning ...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 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?
I do not even know where to start ...yorik wrote:I think it has, don't remember exactly what, but I've seen something about construction phases in the docs.
But I think:yorik wrote:In any case this all goes into the same direction: We should look at what/how others do and build a plan...
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 ...
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.yorik wrote:Maybe the construction phase needs to be like a material? An external object?
Is it possible to create a property for objectgroup? It would be a way to create construction phase.
Re: Macro for BIM simulation of work
I think int/int = 0
casting integer variable to float.
change to
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()
Re: Macro for BIM simulation of work
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 ?
Re: Macro for BIM simulation of work
@ chakkree
Thank you, problem solved.
Thank you, problem solved.
All objects start with 100 (invisible), and the transparency value decreases in proportion to the date's progress until they are visible.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 ?
Re: Macro for BIM simulation of work
Yes, I understood wrongly what the problem with your code was...walpa wrote:All objects start with 100 (invisible), and the transparency value decreases in proportion to the date's progress until they are visible.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 ?
Re: Macro for BIM simulation of work
I ask for help again.
I was able to make a macro that worked as I wanted it
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" Probably some stupidity from line 55 of the Planner.py file.
Any idea?
Thanks.
Walmir
Follow the files ...
I was able to make a macro that worked as I wanted it
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" 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 72 times
-
- Planner.zip
- (18.25 KiB) Downloaded 66 times
-
- Project_test.zip
- (3.05 KiB) Downloaded 68 times
Re: Macro for BIM simulation of work
Problem solved.
The import QTdesigner UI file was the error.
The import QTdesigner UI file was the error.
Re: Macro for BIM simulation of work
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 - click to Create Planner
- search xml file
- click import data and close - on each Arch object, set the Planner_ID property, linking to the activity
- select the Planner group and click Create Simulation 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
Tutorial:
- creating objects on Arch workbench
- access Planner workbench - click to Create Planner
- search xml file
- click import data and close - on each Arch object, set the Planner_ID property, linking to the activity
- select the Planner group and click Create Simulation 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 84 times