- 积分
- 1905
- 明经币
- 个
- 注册时间
- 2022-4-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
- # -*- coding: utf-8 -*
- from System import *
- from pycad.runtime import *
- from pycad.system import *
- from Autodesk.AutoCAD.DatabaseServices import *
- from Autodesk.AutoCAD.Geometry import *
- from Autodesk.AutoCAD.ApplicationServices import *
- from pycad.runtime.edx import *
- from Autodesk.AutoCAD.EditorInput import *
- class LineJig(DrawJig):
- def __init__(self, basept = Point3d):
- self.line = Line(basept, basept)
- self.location = basept
- def Sampler(self, prompts=JigPrompts):
- opts = JigPromptPointOptions('\n请输入终点:')
- opts.UserInputControls = (
- UserInputControls().Accept3dCoordinates |
- UserInputControls().NoZeroResponseAccepted |
- UserInputControls().NoNegativeResponseAccepted)
- res = prompts.AcquirePoint(opts)
- if res.Value != self.location:
- self.location = res.Value
- else:
- return aced.SamplerStatus.NoChange
- if res.Status == aced.PromptStatus.Cancel:
- return aced.SamplerStatus.Cancel
- else:
- return aced.SamplerStatus.OK
- def WorldDraw(self, doc):
- doc.Geometry.Draw(self.GetEntity())
- return True
- def Update(self):
- self.line.EndPoint = self.location
- def GetEntity(self):
- self.Update()
- return self.line
- @command()
- def TLineJig(doc):
- with dbtrans(doc) as tr:
- btr=tr.opencurrspace()
- res = edx.getpoint("\n请输入起点:")
- if not res.ok(): return
- BasePt = res.value
- jig = LineJig(BasePt)
- res = doc.Editor.Drag(jig)
- while (res.Status==PromptStatus().OK):
- line=jig.GetEntity()
- tr.addentity(btr,line)
- tr.flush(line)
- BasePt=jig.location
- jig=LineJig(BasePt)
- res = doc.Editor.Drag(jig)
- if res.Status!=PromptStatus().OK:
- break
-
复制代码
|
|