Skip to content

Commit d7ae91b

Browse files
committed
Create createBox3D.py
1 parent b0ba9fc commit d7ae91b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Script Examples/createBox3D.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Copyright(c) 2021 Hồ Văn Chương
2+
# @chuongmep https://chuongmep.com/
3+
import clr
4+
import sys
5+
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
6+
import os
7+
import math
8+
clr.AddReference('acmgd')
9+
clr.AddReference('acdbmgd')
10+
clr.AddReference('accoremgd')
11+
# Import references from AutoCAD
12+
from Autodesk.AutoCAD.Runtime import *
13+
from Autodesk.AutoCAD.ApplicationServices import *
14+
from Autodesk.AutoCAD.EditorInput import *
15+
from Autodesk.AutoCAD.DatabaseServices import *
16+
from Autodesk.AutoCAD.Geometry import *
17+
doc = Application.DocumentManager.MdiActiveDocument
18+
ed = doc.Editor
19+
db = doc.Database
20+
# Write Code Below
21+
22+
with doc.LockDocument():
23+
with doc.Database as db:
24+
with db.TransactionManager.StartTransaction() as t:
25+
bt = t.GetObject(db.BlockTableId,OpenMode.ForRead)
26+
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
27+
# Do action here
28+
box = Solid3d()
29+
box.CreateBox(1000,2000,3000)
30+
matrix = ed.CurrentUserCoordinateSystem
31+
matrix = matrix * Matrix3d.Displacement(Vector3d(111, 222, 333))
32+
box.TransformBy(matrix)
33+
btr.AppendEntity(box)
34+
t.AddNewlyCreatedDBObject(box, True)
35+
t.Commit()
36+
print("Created Box")

0 commit comments

Comments
 (0)