## why 1pyramid?

Need help, or want to share a macro? Post here!
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

### why 1pyramid?

# -*- coding: utf-8 -*-
import FreeCAD
import Part
import Part,PartGui
from FreeCAD import Base

def kansu(i):
b=1
h=0.5
myWedgei='myPyramid' + str(i)
pyramid=App.ActiveDocument.addObject("Part::Wedge",myWedgei)
pyramid.Xmin=0.00
pyramid.Ymin=0.00
pyramid.Zmin=0.00
pyramid.X2min=b/2
pyramid.Z2min=b/2
pyramid.Xmax=b
pyramid.Ymax=h
pyramid.Zmax=b
pyramid.X2max=b/2
pyramid.Z2max=b/2
pyramid.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
pyramid.Placement=App.Placement(App.Vector(i*2,0,0), App.Rotation(App.Vector(1,0,0),90), App.Vector(0,0,0))
pyramid.recompute()

kansu(1)
kansu(2)
wandererfan
Posts: 4078
Joined: Tue Nov 06, 2012 5:42 pm

### Re: why 1pyramid?

mrrclb48z wrote:
Fri Mar 09, 2018 12:21 pm
code tags, please. too hard to read without them

Code: Select all

``````# -*- coding: utf-8 -*-
import FreeCAD
import Part
import Part,PartGui
from FreeCAD import Base

def kansu(i):
b=1
h=0.5
myWedgei='myPyramid' + str(i)
pyramid=App.ActiveDocument.addObject("Part::Wedge",myWedgei)
pyramid.Xmin=0.00
pyramid.Ymin=0.00
pyramid.Zmin=0.00
pyramid.X2min=b/2
pyramid.Z2min=b/2
pyramid.Xmax=b
pyramid.Ymax=h
pyramid.Zmax=b
pyramid.X2max=b/2
pyramid.Z2max=b/2
pyramid.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
pyramid.Placement=App.Placement(App.Vector(i*2,0,0), App.Rotation(App.Vector(1,0,0),90), App.Vector(0,0,0))
pyramid.recompute()

kansu(1)
kansu(2)``````
2 pyramids here with this version:
OS: Ubuntu 12.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13374 (Git)
Build type: debug
Branch: wmWidget
Hash: c5bc81ce59522a3b0f886f844d46fc3771d89080
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
OCC version: 7.2.0
Locale: English/Canada (en_CA)
kansu.png (144.58 KiB) Viewed 362 times
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

### Re: why 1pyramid?

Thanks

Code: Select all

``````# -*- coding: utf-8 -*-
import FreeCAD
import Part
import Part,PartGui
from FreeCAD import Base

def kansu(i):
b=1
h=0.5
myWedgei='myPyramid' + str(i)
pyramid=App.ActiveDocument.addObject("Part::Wedge",myWedgei)
pyramid.Xmin=0.00
pyramid.Ymin=0.00
pyramid.Zmin=0.00
pyramid.X2min=b/2
pyramid.Z2min=b/2
pyramid.Xmax=b
pyramid.Ymax=h
pyramid.Zmax=b
pyramid.X2max=b/2
pyramid.Z2max=b/2
pyramid.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
pyramid.Placement=App.Placement(App.Vector(i*2,0,0), App.Rotation(App.Vector(1,0,0),90), App.Vector(0,0,0))

kansu(1)
kansu(2)
pyramid.recompute()
``````
－－－－－－－－－－－－－－
(2018/03/13)

Code: Select all

``````# -*- coding: utf-8 -*-
import FreeCAD
import Part
import Part,PartGui
from FreeCAD import Base

def fcPyramid(x,y,b,h):
myWedgei='myPyramid_x' + str(x) + 'y' + str(y)
y=y+b
pyramid=App.ActiveDocument.addObject("Part::Wedge",myWedgei)
pyramid.Xmin=0.00
pyramid.Ymin=0.00
pyramid.Zmin=0.00
pyramid.X2min=b/2
pyramid.Z2min=b/2
pyramid.Xmax=b
pyramid.Ymax=h
pyramid.Zmax=b
pyramid.X2max=b/2
pyramid.Z2max=b/2
pyramid.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
pyramid.Placement=App.Placement(App.Vector(x,y,0), App.Rotation(App.Vector(1,0,0),90), App.Vector(0,0,0))

b=1
h=0.5
fcPyramid(0,0,b,h)
pyramid.recompute()
``````
wrong top x0.5 y0.5