I'm fairly certain you would get an error in the Report View, something starting
Exception....Units... perhaps?
Anyway here's a tested macro, hopefully you'll read everything and understand that numbers and units have to match when carrying out maths against them.
Code: Select all
import FreeCAD as App
doc = App.activeDocument()
plane = doc.addObject("Part::Plane", "myPlane")
planeLength = 30 # This is a plain integer representing a dimention in millimetres
planeWidth = 40 # This is a plain integer representing a dimention in millimetres
offsetInX = 0 # This is a plain integer which can be positive or negative, representing a dimention in millimetres
offsetInY =0 # This is a plain integer which can be positive or negative, representing a dimention in millimetres
zPos = 3 # This is a plain integer which can be positive or negative, representing a dimention in millimetres
xPos = offsetInX-planeLength/2
yPos = offsetInY-planeWidth/2
plane.Length = planeLength
plane.Width = planeWidth
centreOfPlane = FreeCAD.Vector(xPos,yPos,zPos) # This is now a matrix of metric positions in millimetres
rot = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0)
newplace = FreeCAD.Placement(centreOfPlane,rot,centreOfPlane)
plane.Placement = newplace
doc.recompute()