pycad 更改块基点
# -*- coding: utf-8 -*
from pycad.system import *
from pycad.runtime import *
@command()
def reinspt(doc):
with dbtrans(doc) as tr:
obj1 =tr.getobject(edx.entsel("选择要修改的块").ObjectId)
btrec = tr.getobject(obj1.BlockTableRecord,acdb.OpenMode.ForWrite)
bkmat = obj1.BlockTransform
inspt= edx.getpoint("新基点").value.TransformBy(bkmat.Inverse())
btrec.UpgradeOpen()
mat1= acge.Matrix3d.Displacement(btrec.Origin.GetVectorTo(acge.Point3d(0,0,0)))
mat2= acge.Matrix3d.Displacement(inspt.GetAsVector())
btrec.Origin=inspt
ids= btrec.GetBlockReferenceIds(True, False)
for id in ids:
brfobj = tr.getobject(id,acdb.OpenMode.ForWrite)
blkmat = brfobj.BlockTransform
brfobj.Position=inspt.TransformBy(mat1).TransformBy(mat2).TransformBy(blkmat)
ed=doc.Editor
ed.Regen()
学习了,最近我也在学习 pycad。
之前都是用 win32 来用 vba的接口的python开发插件,总是断连。
非常感谢分享。
页:
[1]