Next step, create BS shape codes
Code: Select all
"""
Test Create DWire for rebar axis ,
for concept design of scripted object in future.
check basic rebar shape code.
27 Aug 2016
"""
import Part
import Draft
from FreeCAD import Vector , Placement
def CreateStraightBarHook(A=1000 ,placement = None):
D = +6*12
L1 = 4*12
pt1 = Vector(D/2.0 + L1,0,D)
pt2 = Vector(0,0,D)
pt3 = Vector(0,0,0)
pt4 = Vector(A,0,0)
pt5 = Vector(A,0,D)
pt6 = Vector(A-D/2.0 - L1,0,D)
points = [pt1,pt2,pt3,pt4,pt5,pt6]
axisRebar1 = Draft.makeWire(points,closed=False,face=False,support=None)
#axisRebar1.FilletRadius = D/2.0 # Eroor <class 'Part.OCCError'>: Both points are equal
axisRebar1.FilletRadius = D/2.0 - D*0.000001 # tip for prevent error <class 'Part.OCCError'>: Both points are equal
#axisRebar1.setExpression('FilletRadius', u'+6 * 12 / 2.0')
#axisRebar1.ViewObject.LineColor = (0.00,1.00,1.00)
if placement: axisRebar1.Placement=placement
# ****** find new algorithm for position of Dimension with object
FreeCAD.DraftWorkingPlane.alignToPointAndAxis(Vector(0,0,0), Vector(0,-1,0), 0.0) # XZ plane
ptDim1 = Vector(A/2,0,-100)
Dim1 = Draft.makeDimension(pt3 , pt4 , ptDim1)
Dim1.Direction = (1.00, 0.00, 0.00)
Dim1.ViewObject.FontSize = 50
Dim1.ViewObject.ArrowSize =10
Dim1.ViewObject.ArrowType = "Arrow"
FreeCAD.DraftWorkingPlane.alignToPointAndAxis(Vector(0,0,0), Vector(0,0,1), 0.0)
if placement: axisRebar1.Placement=placement
return axisRebar1
def CreateLShape(A=1000,B=300):
pt1 = Vector(0,0,0)
pt2 = Vector(A,0,0)
pt3 = Vector(A,0,B)
points = [pt1,pt2,pt3]
axisRebar1 = Draft.makeWire(points,closed=False,face=False,support=None)
axisRebar1.FilletRadius = 50
#axisRebar1.ViewObject.LineColor = (0.00,1.00,1.00)
return axisRebar1
#CreateLShape()
rebar1 = CreateStraightBarHook()
FreeCAD.ActiveDocument.recompute()
placement2 = Placement()
placement2.Base.x = 1500
createBSShape01 = CreateStraightBarHook
rebar2 = createBSShape01(placement=placement2)
Msg('rebar1 length = {}\n'.format(rebar1.Length) )