# import
import PyRx as Rx
import PyGe as Ge
import PyGi as Gi
import PyDb as Db
import PyAp as Ap
import PyEd as Ed
import traceback
def PyRxCmd_doit():
try:
for pattern in Ed.Core.getPredefinedHatchPatterns():
print(pattern)
except Exception as err:
traceback.print_exception(err)
def PyRxCmd_doit2():
try:
res = Ed.Core.hatchPalletteDialog("", False)
pycreate_hatch(res, False)
except Exception as err:
traceback.print_exception(err)
def PyRxCmd_doit3():
try:
res = Ed.Core.hatchPalletteDialog("", True)
pycreate_hatch(res,True )
except Exception as err:
traceback.print_exception(err)
def pycreate_hatch(srafura : str, isCustom : bool):
try:
db = Db.HostApplicationServices().workingDatabase()
hatch = Db.Hatch()
hatch.setDatabaseDefaults()
normal = Ge.Vector3d(0,0,1)
hatch.setNormal(normal)
hatch.setElevation(0)
hatch.setAssociative(False)
if isCustom:
hatch.setPattern(Db.HatchPatternType.kCustomDefined, srafura)
else:
hatch.setPattern(Db.HatchPatternType.kPreDefined, srafura)
hatch.setHatchStyle(Db.HatchStyle.kNormal)
vertexPts = []
vertexPts.append(Ge.Point2d(2.0, 2.0))
vertexPts.append(Ge.Point2d(18.0, 2.0))
vertexPts.append(Ge.Point2d(18.0, 18.0))
vertexPts.append(Ge.Point2d(2.0, 18.0))
vertexPts.append(Ge.Point2d(2.0, 2.0))
vertexBulges = []
for n in range(len(vertexPts)):
vertexBulges.append(0.0)
hatch.appendLoopBulges(Db.HatchLoopType.kExternal, vertexPts, vertexBulges)
cenPt = Ge.Point2d(10.0, 10.0)
TWOPI = 2.0 * 3.1415926535897932
cirArc = Ge.CircArc2d()
cirArc.setCenter(cenPt)
cirArc.setRadius(4.0)
cirArc.setAngles(0.0, TWOPI)
edgePtrs = []
edgeTypes = []
edgePtrs.append(cirArc)
edgeTypes.append(Db.HatchEdgeType.kCirArc)
hatch.appendLoopEdges(Db.HatchLoopType.kDefault, edgePtrs, edgeTypes)
hatch.evaluateHatch()
model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
model.appendAcDbEntity(hatch)
except Exception as err:
traceback.print_exception(err)