Tip: Storey Slide

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
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Tip: Storey Slide

Post by chakkree »

In BIM Vision has storey slide ability.
I try to make FreeCAD like ,that but use python command
The Floor in model should define name(already defined in python script)
This trick can not use for all model.
Assume all floor position is (0,0,0) for reset position

slide floor in x direction (change x to y or z for desired direction)
slide_step = 12000

FreeCAD.ActiveDocument.Floor2.Placement.Base.x +=slide_step
FreeCAD.ActiveDocument.FloorRoof.Placement.Base.x +=slide_step*2
FreeCAD.ActiveDocument.recompute()
and reset floor position
FreeCAD.ActiveDocument.Floor2.Placement.Base = Vector(0,0,0)
FreeCAD.ActiveDocument.FloorRoof.Placement.Base = Vector(0,0,0)
FreeCAD.ActiveDocument.recompute()
P.S. there has some mistake in a roof , I'll learn about roof setting to fixed.

Code: Select all

"""
 CreateHome09_LOD1.py
 
"""

from FreeCAD import Vector ,Rotation
from math import radians , tan
import Draft ,Arch , Part



"""
  Floor1
"""
z1 = 600
ht1 = 3150
points1=[
  Vector(5000,1500,z1) , 
  Vector(5000,1500+3500,z1),
  Vector(-600,1500+3500,z1),
  Vector(-600,1500+3500+2300+2700,z1),
  Vector(8500,1500+3500+2300+2700,z1),
  Vector(8500,1500+3500,z1),
  Vector(8500+600,1500+3500,z1),
  Vector(8500+600,1500,z1),
  Vector(8500,1500,z1),
]

LineOfOuterWall= Draft.makeWire(points1,closed=False,face=False,support=None)
LineOfOuterWall.MakeFace = False
Wall1 = Arch.makeWall( LineOfOuterWall , height=ht1 , width = 100)
Wall1.Label = 'Wall_Floor1_Outer'

LineOfOuterSlab= Draft.makeWire(points1,closed=True,face=False,support=None)
Slab1 = Arch.makeStructure(LineOfOuterSlab)
Slab1.Height = 100
Slab1.Role='Slab'
Slab1.Label='Slab_Floor1_main'
Slab1.MoveWithHost = True

# Terrace
z1_2 = z1-100
points1_2=[
  Vector(5000,0,z1_2) , 
  Vector(5000,1500,z1_2) ,
  Vector(8500,1500,z1_2) ,
  Vector(8500,0,z1_2) ,
]
LineOfOuterSlab1_2= Draft.makeWire(points1_2,closed=True,face=False,support=None)
Slab1_2 = Arch.makeStructure(LineOfOuterSlab1_2)
Slab1_2.Height = 100
Slab1_2.Role='Slab'
Slab1_2.Label='Slab_Floor1_Terrace'
Slab1_2.MoveWithHost = True

# Parking
z1_3 = z1-400
points1_3=[
  Vector(0,0,z1_3) , 
  Vector(0,5000,z1_3) ,
  Vector(5000,5000,z1_3) ,
  Vector(5000,0,z1_3) ,
]
LineOfOuterSlab1_3= Draft.makeWire(points1_3,closed=True,face=False,support=None)
Slab1_3 = Arch.makeStructure(LineOfOuterSlab1_3)
Slab1_3.Height = 100
Slab1_3.Role='Slab'
Slab1_3.Label='Slab_Floor1_Parking'
Slab1_3.MoveWithHost = True


"""
  Floor2
"""
z2 = z1 + 3150
ht2 = 2900+800
points2 = [
  Vector(5000,1500,z2) , 
  Vector(0,1500,z2) ,
  Vector(0,10000,z2) ,
  Vector(3300,10000,z2) ,
  Vector(3300,10000+1100,z2) ,
  Vector(5000,10000+1100,z2) ,
  Vector(5000,10000,z2) ,
  Vector(8500,10000,z2) ,
  Vector(8500,1500,z2) ,
]

LineOfOuterWall2= Draft.makeWire(points2,closed=False,face=False,support=None)
LineOfOuterWall2.MakeFace = False
Wall2 = Arch.makeWall( LineOfOuterWall2 , height=ht2 , width = 100)
Wall2.Label = 'Wall_Floor2_Outer'
Wall2.MoveWithHost = True

LineOfOuterSlab2= Draft.makeWire(points2,closed=True,face=False,support=None)
Slab2 = Arch.makeStructure(LineOfOuterSlab2)
Slab2.Height = 100
Slab2.Role='Slab'
Slab2.Label='Slab_Floor2_Main'
Slab2.MoveWithHost = True

# balcony
z2_2 = z2-100
points2_2=[
  Vector(5000,0,z2_2) , 
  Vector(5000,1500,z2_2) ,
  Vector(8500,1500,z2_2) ,
  Vector(8500,0,z2_2) ,
]

LineOfOuterSlab2_2= Draft.makeWire(points2_2,closed=True,face=False,support=None)
Slab2_2 = Arch.makeStructure(LineOfOuterSlab2_2)
Slab2_2.Height = 100
Slab2_2.Role='Slab'
Slab2_2.Label='Slab_Floor1_balcony'
Slab2_2.MoveWithHost = True

"""
   Roof
"""
zRoof = 7450 + 50
points3=[
  Vector(0,1500,zRoof) , 
  Vector(0,10000,zRoof) , 
  Vector(8500,10000,zRoof) , 
  Vector(8500,0,zRoof) , 
  Vector(5000,0,zRoof) ,
  Vector(5000,1500,zRoof) ,
]

points3=[
  Vector(0,10000,zRoof) , 
  Vector(0,1500,zRoof) , 
  Vector(5000,1500,zRoof) ,
  Vector(5000,0,zRoof) ,
  Vector(8500,0,zRoof) , 
  Vector(8500,10000,zRoof) ,
]

LineOfOuterRoof= Draft.makeWire(points3,closed=True,face=False,support=None)
Roof = Arch.makeRoof(LineOfOuterRoof)
Roof.Angles = [35,0,35,0,0,0]
Roof.IdRel = [0,0,1,2,1,1]
Roof.Overhang = [1000,1000,1000,1000,1000,1000]
Roof.MoveWithHost = True


#Roof.Heights = [3000,1225,1225,3000,3000,3000]
Roof.Runs = [+8500/2 , 0 ,+3500/2,0 ,0 ,0 ]
Roof.Role='Roof'

#-------------------------------------------------------
Flr_1 = Arch.makeFloor([Wall1 ,Slab1 , Slab1_2 ,Slab1_3] , name='Floor1')



Flr_2 = Arch.makeFloor([Wall2, Slab2,Slab2_2], name='Floor2')


Flr_Roof = Arch.makeFloor([Roof], name='FloorRoof')




myHome9 = Arch.makeBuilding([Flr_1,Flr_2,Flr_Roof])

mySite = Arch.makeSite()
mySite.addObject(myHome9)


"""
# Python Console can be take effect
# slide floor script
slide_step = 12000

FreeCAD.ActiveDocument.Floor2.Placement.Base.x +=slide_step
FreeCAD.ActiveDocument.FloorRoof.Placement.Base.x +=slide_step*2
FreeCAD.ActiveDocument.recompute()

slide_z_step = 4000
FreeCAD.ActiveDocument.Floor2.Placement.Base.z +=slide_z_step
FreeCAD.ActiveDocument.FloorRoof.Placement.Base.z +=slide_z_step*2
FreeCAD.ActiveDocument.recompute()


FreeCAD.ActiveDocument.Floor2.Placement.Base = Vector(0,0,0)
FreeCAD.ActiveDocument.FloorRoof.Placement.Base = Vector(0,0,0)
FreeCAD.ActiveDocument.recompute()
"""



FreeCAD.ActiveDocument.recompute()
Msg('\nDone!!\n\n')

BimVision_Storey_Slide.png
BimVision_Storey_Slide.png (222.97 KiB) Viewed 1455 times
FreeCAD_Storey_Slide.png
FreeCAD_Storey_Slide.png (156.01 KiB) Viewed 1455 times
FreeCAD_Storey_SlideZ.png
FreeCAD_Storey_SlideZ.png (152.55 KiB) Viewed 1455 times
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Tip: Storey Slide

Post by yorik »

Nice idea! Although it might become heavy to change all the placements in huge models. An intetesting solution would be to change only the coin nodes...

If we were to use the new PartDesign body stuff for that, this kind of thing could become much, much easier..
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Tip: Storey Slide

Post by chakkree »

@Yorik Thank you.
I'm trying to learn Pyside&Coin. I think I used Coin to display transparent in glass panel.

PartDesign Next, it's very interesting.
Both are new to me. :)
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Tip: Storey Slide

Post by chakkree »

Following advice from Yorik, the results below.
This will not disturb with the position data of the object.

slide in x direction

Code: Select all

slide_step = 15000
for obj in  FreeCAD.ActiveDocument.Floor2.Group:
    sg = obj.ViewObject.RootNode
    tran = sg.getChildren()[0]
    tran.translation = [slide_step,0,00]

for obj in  FreeCAD.ActiveDocument.FloorRoof.Group:
    sg = obj.ViewObject.RootNode
    tran = sg.getChildren()[0]
    tran.translation = [slide_step*2,0,00]
Reset

Code: Select all

# Reset
for obj in  FreeCAD.ActiveDocument.Floor2.Group:
    sg = obj.ViewObject.RootNode
    tran = sg.getChildren()[0]
    tran.translation = [0,0,00]

for obj in  FreeCAD.ActiveDocument.FloorRoof.Group:
    sg = obj.ViewObject.RootNode
    tran = sg.getChildren()[0]
    tran.translation = [0,0,00]
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Tip: Storey Slide

Post by yorik »

Excellent! The other cool thing with that method is also that you can easily shift floors with thousands of objects... No slowdown
Post Reply