?2. I want argument ----> array or class
macro---->short source
I do not understand Python.
Thank you in advance and sorry for the bad english!
Code: Select all
import FreeCAD
import Part
import DraftTools
import Draft
import Mesh
def myPyramidCal(xIn,yIn,bIn,hIn):
x = float(xIn)
y = float(yIn)
b = float(bIn)
h = float(hIn)
x2 = x+b*0.5
y2 = y+b*0.5
x3 = x+b
y3 = y+b
z = 0
z2 = h
P1x=x
P1y=y
P1z=z
P2x=x
P2y=y3
P2z=z
P3x=x3
P3y=y3
P3z=z
P4x=x3
P4y=y
P4z=z
P5x=x2
P5y=y2
P5z=z2
return P1x,P1y,P1z,P2x,P2y,P2z,P3x,P3y,P3z,P4x,P4y,P4z,P5x,P5y,P5z
def myPyramidSld(P1x,P1y,P1z,P2x,P2y,P2z,P3x,P3y,P3z,P4x,P4y,P4z,P5x,P5y,P5z):
a =[[x,y,z], #dummy
[P1x,P1y,P1z],
[P2x,P2y,P2z],
[P3x,P3y,P3z],
[P4x,P4y,P4z],
[P5x,P5y,P5z]]
m1 = Mesh.Mesh([a[2],a[5],a[3]])
m2 = Mesh.Mesh([a[4],a[5],a[1]])
m3 = Mesh.Mesh([a[1],a[5],a[4]])
m4 = Mesh.Mesh([a[4],a[3],a[5]])
m5 = Mesh.Mesh([a[1],a[2],a[3],a[1],a[3],a[4]])
mesh=Mesh.Mesh()
mesh.addMesh(m1)
mesh.addMesh(m2)
mesh.addMesh(m3)
mesh.addMesh(m4)
mesh.addMesh(m5)
shape = Part.Shape()
shape.makeShapeFromMesh(mesh.Topology,0.05)
solid = Part.makeSolid(shape).removeSplitter()
myWedgei='x' + str(P1x) + 'y' + str(P1y)+ 'z' + str(P1z)
f = App.activeDocument().addObject("Part::Feature",myWedgei)
f.Shape = solid
def myTxtXYZ(P5x,P5y,P5z):
myWedgei='x' + str(P5x) + 'y' + str(P5y)+ 'z' + str(P5z)
p5 = FreeCAD.Vector(P5x,P5y,P5z)
myText = Draft.makeText(myWedgei,p5)
myText.Label = myWedgei
b=1
h=1
P1x,P1y,P1z,P2x,P2y,P2z,P3x,P3y,P3z,P4x,P4y,P4z,P5x,P5y,P5z=myPyramidCal(0,0,b,h)
myPyramidSld(P1x,P1y,P1z,P2x,P2y,P2z,P3x,P3y,P3z,P4x,P4y,P4z,P5x,P5y,P5z)
myTxtXYZ(P5x,P5y,P5z)
App.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewAxonometric()
Gui.SendMsgToActiveView("ViewFit")
Traceback (most recent call last): File "xxx.FCMacro",
line 66, in myPyramidSld(P1x,P1y,P1z,P2x,P2y,P2z,P3x,P3y,P3z,P4x,P4y,P4z,P5x,P5y,P5z) File "xxx.FCMacro",
line 34, in myPyramidSld a =[[x,y,z], #dummy : global name 'x' is not defined