工作点Lisp
嘿伙计们,我试图制作一个lisp,用户可以在模型中选择一个点,lisp可以使用从模型中提取的坐标在纸空间中创建一个多重引线。
以下是我目前掌握的代码:
(defun c:test (/ WorkingPoint Easting Northing Point)
(command
"_.mspace"
);;end command
(setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
(setq Northing (cadr WorkingPoint));;set "y" value of WorkingPoint to Northing
(setq Easting (car WorkingPoint));;set "x" value of WorkingPoint to Easting
(command
"_.point" WorkingPoint
);;end command
(setq point (entlast));;set the workingpoint to point
(command
"_.chspace" point "" ""
);;end command
(setq pspaceworkingpoint (entget point))
(setq mleaderinspt (list (car pspaceworkingpoint)(cadr pspaceworkingpoint)))
(princ mleadinspt)
);;end defun
每当我运行它时,对于“mleaderinspt”变量,我得到
nilnil
我想做的是创建多重引线插入点,用户在其中选择原始工作点,但我很难将其转换到图纸空间。
请注意,我还没有添加错误检查,因为这仍处于开发阶段/概念验证。
非常感谢您的帮助。
谢谢
编辑:我想我已经解决了,如果可行的话,我会更新这个线程。 好的,这就是我的观点:
(defun c:test (/ WorkingPoint Easting Northing Point)
(command
"_.mspace"
);;end command
(setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
(setq Northing (cadr WorkingPoint));;set "y" value of WorkingPoint to Northing
(setq Easting (car WorkingPoint));;set "x" value of WorkingPoint to Easting
(command
"_.point" WorkingPoint
);;end command
(setq point (entlast));;set the workingpoint to point
(command
"_.chspace" point "" ""
);;end command
(setq pspacepoint (entget point))
(setq pspace (cdr (assoc 10 pspacepoint)))
(command
"_.mleader" pspace "@10,-10" "WORKING POINT N "
)
);;end defun
我在让多重引线输入文本时遇到问题。。。我们使用的典型格式是:
工作点
N: XXXXX公司
E: XXXXX公司
我不知道如何让它像这样显示。。。思想?我尝试使用“strcat”,但它不接受我研究中的整数。
也就是坐标,是这样的“2.485834611853077E+005”,我只需要它是“248583.46”,关于如何补救这个问题,有什么想法吗?
谢谢
Command: (rtos (atof "2.485834611853077E+005") 2 2)
"248583.46"
完美的这帮我解决了一个问题 你使用了很多保留字点,pspsace对于变量名不是一个好主意,这可能会产生问题。 我想出了一个暂时可行的方法,格式有点不合适,但用户可以通过编辑引线来修复它(可能需要命名工作点)。
(defun c:test (/ WorkingPoint Easting Northing Point PSPACEPOINT PSPACE TEXT TEXTPROPS COORD)
(command
"_.mspace"
);;end command
(setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
(setq Northing (rtos (cadr WorkingPoint) 2 1));;set "y" value of WorkingPoint to Northing
(setq Easting (rtos (car WorkingPoint) 2 1));;set "x" value of WorkingPoint to Easting
(command
"_.point" WorkingPoint
);;end command
(setq point (entlast));;set the workingpoint to point
(command
"_.chspace" point "" "";;this brings the workingpoint set in the modelspace to paperspace
);;end command
(setq pspacepoint (entget point));;get the properties for point
(setq pspace (cdr (assoc 10 pspacepoint)));;find the x&y coords and set to pspace
(COMMAND
"mTEXT" PSPACE "@20,-20" "WORKING POINT" "N:"NORTHING "E:"EASTING ""
);;END COMMAND
(setq text (entlast));;set mtext to variable text
(setq textprops (entget text));;get the properties from text
(setq coord (cdr (assoc 1 textprops)));;find the string properties and set to coord
(command
"_.mleader" pspace "@10,-10" coord
"_.erase" point text ""
);;END COMMAND
);;end defun
页:
[1]