此Lisp pl有问题
亲爱的朋友们我试图制作这个lisp来制作xyz坐标系,但在z级别有一些问题,请在这方面帮助我,以下是lisp
(defun c:cott()
(princ "\nthis lsp to type the coordinate x,y.& z make table")
;(command "osnap" "none" )
(command "osnap" "node,inter" )
(setq p(getpoint "\n Enter First Point :")
pp(getpoint "\n Enter Second Point :")
u(getint "\n Enter start point number:")
tab(getpoint "\n Enter Upper Left Corner of Table:")
u1 (+ 1 u)
x(car p)
y(cadr p)
z(caddr p)
x1(car pp)
y1(cadr pp)
z1(caddr pp)
text(strcat "(" (rtos x 2 3) "," (rtos y 2 3)")")
text1(strcat "(" (rtos x1 2 3) "," (rtos y1 2 3) ")")
p1(mapcar '+ p (list 0.35 0.45))
p2(mapcar '+ pp (list 0.35 0.45))
p10(mapcar '+ p (list 0.35 -0.45))
p11(mapcar '+ pp (list 0.35 -0.45))
tab1(mapcar '+ tab (list 2 0 ))
tab2(mapcar '+ tab (list 4 0 ))
tab3(mapcar '+ tab (list 6 0 ))
tab4(mapcar '+ tab (list 8 0 ))
tab5(mapcar '+ tab (list 0 -1 ))
tab6(mapcar '+ tab1 (list 0 -1 ))
tab7(mapcar '+ tab2 (list 0 -1 ))
tab8(mapcar '+ tab3 (list 0 -1 ))
tab9(mapcar '+ tab4 (list 0 -1 ))
tab10(mapcar '+ tab5 (list 0 -1))
tab11(mapcar '+ tab6 (list 0 -1))
tab12(mapcar '+ tab7 (list 0 -1))
tab13(mapcar '+ tab8 (list 0 -1))
tab14(mapcar '+ tab9 (list 0 -1))
tab15(mapcar '+ tab10 (list 0 -1))
tab16(mapcar '+ tab11 (list 0 -1))
tab17(mapcar '+ tab12 (list 0 -1))
tab18(mapcar '+ tab13 (list 0 -1))
tab19(mapcar '+ tab14 (list 0 -1))
POIN(mapcar '+ tab (list 0.45 -0.7))
POIN1(mapcar '+ tab1 (list 0.35 -0.7))
POIN2(mapcar '+ tab2 (list 0.35 -0.7))
POIN3(mapcar '+ tab3 (list 0.35 -0.7))
POIN4(mapcar '+ tab5 (list 0.68 -0.7))
POIN5(mapcar '+ tab6 (list 1 -0.5))
POIN6(mapcar '+ tab7 (list 1 -0.5))
POIN7(mapcar '+ tab8 (list 1 -0.5))
POIN8(mapcar '+ poin4 (list 0 -1))
POIN9(mapcar '+ poin5 (list 0 -1))
POIN10(mapcar '+ poin6 (list 0 -1))
POIN11(mapcar '+ poin7 (list 0 -1))
uu(strcat "" (itoa u) )
uu1(strcat "" (itoa u1) )
)
(command "osnap" "none" )
; (command "Style" n "" "" "" "" "" "" "")
(command "style" "ahmedn" "txt" "0.2" "1" "0" "n" "n" "n" "")
;(command "line" p pp "")
(command "line" tab tab4 "")
(command "line" tab5 tab8 "")
(command "line" tab10 tab13 "")
(command "line" tab15 tab18 "")
(command "line" tab tab15 "")
(command "line" tab1 tab16 "")
(command "line" tab2 tab17 "")
(command "line" tab3 tab18 "")
(command "line" tab4 tab19 "")
;(command "text" P1 "0"text "")
;(command "text" P2 "0"text1 "")
(command "text" P10 "0"uu "")
(command "text" P11 "0"uu1 "")
(command "text" poin "0""REF.#" "")
(command "text" poin1 "0""EASTING" "")
(command "text" poin2 "0""NORTHING" "")
(command "text" poin3 "0""LEVEL" "")
(command "text" poin4 "0" uu "")
(command "text" poin8 "0" uu1 "")
(command "text" "j" "mc" poin5 "0" (rtos x 2 3) "")
(command "text" "j" "mc" poin6 "0" (rtos y 2 3) "")
(command "text" "j" "mc" poin7 "0" (rtos z 2 3) "")
(command "text" "j" "mc" poin9 "0" (rtos x1 2 3) "")
(command "text" "j" "mc" poin10 "0" (rtos y1 2 3) "")
(command "text" "j" "mc" poin11 "0" (rtos z1 2 3) "")
(command "osnap" "node,inter" )
(command "osnap" "node,inter" )
(setqppp(getpoint "\n Enter Next Point :") )
(while ( /= ppp nil )
(progn
(setq
u1 (+ 1 u1)
x1(car ppp)
y1(cadr ppp)
z1(caddr pp)
text1(strcat "(" (rtos x1 2 3) "," (rtos y1 2 3) ")")
p2(mapcar '+ ppp (list 0.35 0.45))
p11(mapcar '+ ppp (list 0.35 -0.45))
uu1(strcat "" (itoa u1) )
tab15(mapcar '+ tab15 (list 0 -1))
tab16(mapcar '+ tab16 (list 0 -1))
tab17(mapcar '+ tab17 (list 0 -1))
tab18(mapcar '+ tab18 (list 0 -1))
tab19(mapcar '+ tab19 (list 0 -1))
POIN8(mapcar '+ poin8 (list 0 -1))
POIN9(mapcar '+ poin9 (list 0 -1))
POIN10(mapcar '+ poin10 (list 0 -1))
POIN11(mapcar '+ poin11 (list 0 -1))
);setq
(command "osnap," "none" )
; (command "line" pp ppp "")
;(command "text" p2 "0"text1 "")
(command "text" p11 "0"uu1 "")
(command "text" poin8 "0" uu1 "")
(command "text" "j" "mc" poin9 "0" (rtos x1 2 3) "")
(command "text" "j" "mc" poin10 "0" (rtos y1 2 3) "")
(command "text" "j" "mc" poin11 "0" (rtos z1 2 3) "")
(command "line" tab15 tab18 "")
(setq pp ppp
;u1 (+ 1 u1)
);setq
(command "osnap" "node,inter" )
(setqppp(getpoint "\n Enter Next Point :"))
);progn
) ;while
(command "osnap" "none" )
(command "line" tab tab15 "")
(command "line" tab1 tab16 "")
(command "line" tab2 tab17 "")
(command "line" tab3 tab18 "")
(command "line" tab4 tab19 "")
(command "osnap" "node,inter" )
);end 请阅读代码发布指南并编辑您的帖子,将代码包含在代码标签中。
Your Code Here 您是否想过使用“Autocad表格”而不是文字周围的线条,这可能会容易得多。下面是一个例子。下面第三个代码中的建议。
; example of creating a table
; apologise not sure where I got this code
(defun c:sct (/ colwidth numcolumns numrows objtable rowheight sp vgad vgao )
(vl-load-com)
(setq sp (vlax-3d-point '(0 0 0)))
;(setq vgao (vlax-get-acad-object))
;(setq vgad (vla-get-activedocument vgao))
;(setq vgms (vla-get-paperspace vgad))
(setq doc(vla-get-activedocument (vlax-get-acad-object) ))
(setq vgms (vla-get-paperspace doc))
(setq numrows 5)
(setq numcolumns 5)
(setq rowheight 0.5)
(setq colwidth 30)
(setq objtable (vla-addtable vgms sp numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "TABLE title")
(vla-settext objtable 1 0 "A")
(vla-settext objtable 1 1 "B")
(vla-settext objtable 1 2 "C")
(vla-settext objtable 1 3 "D")
(vla-settext objtable 1 4 "E")
(vla-settext objtable 2 0 "1")
(vla-settext objtable 3 0 "2")
(vla-settext objtable 4 0 "3")
(vla-setcolumnwidth objtable 0 15) ; 0 is first column
(vla-setcolumnwidth objtable 1 30)
(vla-setcolumnwidth objtable 2 60)
(command "_zoom" "e")
(princ)
)
(C:sct)
另一个示例行数未知
; dwg index to a table
; by Alan H NOV 2013
(defun AH:dwgindex (/ doc objtable ss1 lay ans ans2 plotabs ss1 tag2 tag3 list1 list2 curlayout colwidth numcolumns numrows INC rowheight )
(vl-load-com)
(setq curlayout (getvar "ctab"))
(if (= curlayout "Model")
(progn
(Alert "You need to be in a layout for this option")
(exit)
) ; end progn
) ; end if model
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq curspace (vla-get-paperspace doc))
(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:")))
; read values from title blocks
(setq bname "DA1DRTXT")
(setq tag2 "DRG_NO") ;attribute tag name
(setq tag3 "WORKS_DESCRIPTION") ;attribute tag name
(setq ss1 (ssget "x"(list (cons 0 "INSERT") (cons 2 bname))))
(if (= ss1 nil) ; for tomkinson jobs
(progn
(setq bname "COGG_TITLE")
(setq ss1 (ssget "x"(list (cons 0 "INSERT") (cons 2 bname))))
)
)
(setq INC (sslength ss1))
(repeat INC
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (SETQ INC (- INC 1)) )) 'getattributes)
(if (= tag2 (strcase (vla-get-tagstring att)))
(progn
(setq ans (vla-get-textstring att))
(if (/= ans NIL)
(setq list1 (cons ans list1))
) ; if
); end progn
) ; end if
(if (= tag3 (strcase (vla-get-tagstring att)))
(progn
(setq ans2 (vla-get-textstring att))
(if (/= ans2 NIL)
(setq list2 (cons ans2 list2))
) ; end if
) ; end progn
) ; end if tag3
) ; end foreach
) ; end repeat
(setvar 'ctab curlayout)
(command "Zoom" "E")
(command "regen")
(reverse list1)
;(reverse list2)
; now do table
(setq numrows (+ 2 (sslength ss1)))
(setq numcolumns 2)
(setq rowheight 0.2)
(setq colwidth 150)
(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "DRAWING REGISTER")
(vla-settext objtable 1 0 "DRAWING NUMBER")
(vla-settext objtable 1 1 "DRAWING TITLE")
(SETQ X 0)
(SETQ Y 2)
(REPEAT (sslength ss1)
(vla-settext objtable Y 0 (NTH X LIST1))
(vla-settext objtable Y 1 (NTH X LIST2))
(vla-setrowheight objtable y 7)
(SETQ X (+ X 1))
(SETQ Y (+ Y 1))
)
(vla-setcolumnwidth objtable 0 55)
(vla-setcolumnwidth objtable 1 170)
(command "_zoom" "e")
); end AH defun
(AH:dwgindex)
(princ)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 40 ) ;this is int & node ; 0 is non
..... at end of code
(setvar "osmode" Oldsnap)
您使用的是引号标记而不是代码标记,我这次为您修复了它,但请下次使用正确的标记。 嗨,nafees。
我同意Bigal的观点,在开始时获取osmode变量,并在结束时使用该值恢复它。让lisp例程将变量重置回任意值,而不是将它们恢复到lisp执行之前的状态,这从来都不是一件有趣的事。还应考虑以下因素
-如果用户取消(转义),将变量恢复为初始值的错误处理
-尽量减少使用功能命令(即(setvar“osmode”40)而不是(命令“osnap”“node,inter”)。。
此外,就在最后一个while语句之前,您一行有2次(命令“osnap”“node,inter”)
要解决您的Z问题,请在您最后的“while”语句中找到以下内容。。。
(setq
u1 (+ 1 u1)
x1(car ppp)
y1(cadr ppp)
z1(caddr pp)
并将z1替换为z1(caddr ppp)
干杯 尊敬的Jef:
我已根据您的建议进行了修改,但不起作用。请检查我再次附加在这里的lisp
我无法纠正我的错误,请在这件事上帮助我。。谢谢大家 Works为我画了一条3d线,但我认为你的OSNAP已经关闭,Node&inter&也许结束了。(setvar“osmode”41)另外,您的水平线不太正确,但我将把它留给您。如果您希望此表用于放样,则可能需要添加数据的写入文件。
正如注释一样,我们以不同的方式创建点编号的气泡,导出为csv文件,然后读取csv文件以制作表格,如果添加点,则只需删除并重新创建。看看这个http://www.cadtutor.net/forum/showthread.php?96174-LISP自动标签编号系统Clint
7 非常感谢BIGAL它现在正在工作。。。谢谢
页:
[1]