entmake Lisp中的多行
大家好。这是我在这个精彩的论坛上的第一篇帖子,我希望我能在这个宝贵的论坛上受到欢迎。
我知道如何处理Autolisp,但不是那么多,所以我需要使用带有圆角和封闭边的Entmake的多行lisp,这可能吗??
非常感谢
迈克尔。 嵌入MLine非常麻烦,并且会导致异常-您可以嵌入MLineStyle,但最好使用ActiveX方法创建MLine对象本身。
以下是几个示例函数:
;;-------------------=={ Add MLine Style }==------------------;;
;; ;;
;;Adds an MLine Style to the ACAD_MLINESTYLE dictionary ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;data - a DXF list of MLineStyle data ;;
;;------------------------------------------------------------;;
;;Returns:MLineStyle Dictionary Entity, else nil ;;
;;------------------------------------------------------------;;
(defun LM:AddMLineStyle ( data / dic obj )
;; © Lee Mac 2010
(if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
(not (dictsearch (setq dic (cdr (assoc -1 dic))) (cdr (assoc 2 data))))
(setq obj (entmakex data)))
(dictadd dic (cdr (assoc 2 data)) obj)
)
)
;;-----------------=={ Delete MLine Style }==-----------------;;
;; ;;
;;Removes an MLine Style from the ACAD_MLINESTYLE ;;
;;dictionary ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;name - the name of an MLine Style to remove ;;
;;------------------------------------------------------------;;
;;Returns:Entity name of removed style, else nil ;;
;;------------------------------------------------------------;;
(defun LM:DeleteMLineStyle ( name / dic )
;; © Lee Mac 2010
(if (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
(dictremove (cdr (assoc -1 dic)) name)
)
)
;;------------------------------------------------------------;;
;; Test Function
(defun Example ( / lst )
(setq lst
(list
(cons 0 "MLINESTYLE")
(cons 100 "AcDbMlineStyle")
(cons 2 "Example") ; Name
(cons 70 (+ 272)); caps/fill/joints
(cons 3 "") ; Desc
(cons 51 (/ pi 2.)); Start ang
(cons 52 (/ pi 2.)); End ang
(cons 71 2) ; Number of lines
(cons 49 -0.5) ; Element Offset
(cons 62 256) ; Element Colour
(cons 6 "BYLAYER") ; Element Linetype
(cons 49 0.5)
(cons 62 256)
(cons 6 "BYLAYER")
)
)
(LM:AddMLineStyle lst)
)
;;----------------------=={ Add MLine }==---------------------;;
;; ;;
;;Adds a VLA MLine Object to the supplied Block container ;;
;;object, going through the supplied vertex list. ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;space - VLA Block Object ;;
;;ptLst - List of 3D Points for MLine Vertices ;;
;;------------------------------------------------------------;;
;;Returns:VLA MLine Object, else nil ;;
;;------------------------------------------------------------;;
(defun LM:AddMLine ( space ptLst )
;; © Lee Mac 2010
(vla-AddMline space (LM:PointVariant ptLst))
)
;;------------------=={ Safearray Variant }==-----------------;;
;; ;;
;;Creates a populated Safearray Variant of a specified ;;
;;data type ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;datatype - variant type enum (eg vlax-vbDouble) ;;
;;data - list of static type data ;;
;;------------------------------------------------------------;;
;;Returns:VLA Variant Object of type specified ;;
;;------------------------------------------------------------;;
(defun LM:SafearrayVariant ( datatype data )
;; © Lee Mac 2010
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray datatype
(cons 0 (1- (length data)))
)
data
)
)
)
;;--------------------=={ Point Variant }==-------------------;;
;; ;;
;;Creates a populated Safearray Variant of Double type. ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;lst - list of 2D/3D Points to populate the Variant. ;;
;;------------------------------------------------------------;;
;;Returns:VLA Safearray Variant ;;
;;------------------------------------------------------------;;
(defun LM:PointVariant ( lst )
;; © Lee Mac 2010
(LM:SafearrayVariant vlax-VBDouble (apply 'append lst))
)
;;---------------------=={ Get Points }==---------------------;;
;; ;;
;;Returns a list of selected points. ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;;Arguments: - None - ;;
;;------------------------------------------------------------;;
;;Returns:List of 3D Points ;;
;;------------------------------------------------------------;;
(defun LM:GetPoints ( / lst pt )
;; © Lee Mac 2010
(if (car (setq lst (list (getpoint "\nPick First Point: "))))
(while (setq pt (getpoint "\nPick Next Point: " (car lst)))
(mapcar
(function
(lambda ( from to ) (grdraw from to 3 1))
)
(cdr (reverse (setq lst (cons pt lst))))
(reverse (cdr lst))
)
)
)
(redraw) (reverse lst)
)
;;------------------------------------------------------------;;
;; Test Function
(defun c:test ( / lst )
(if (setq lst (LM:GetPoints))
(LM:AddMLine
(vla-get-ModelSpace
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
lst
)
)
)
IMO,为了视觉效果和易用性,在本例中只需使用(命令“_.mline”)。 非常感谢。
它一直运行到最后一点,在结束错误时,没有绘制任何内容。
命令行中的错误消息。
; error: no function definition: VLAX-GET-ACAD-OBJECT
仅作为透明绿线运行的程序。
任何解决方案。
迈克尔
我发现它可以将多线绘制到每个点,但在最后留下了这个消息。
#
尝试添加VL-LOAD-COM,我通常将其保存在我的acaddoc中。lsp
(defun c:test ( / lst )
(vl-load-com)
Loads Visual LISP extensions to AutoLISP
(vl-load-com)
This function loads the extended AutoLISP functions provided
with Visual LISP. The Visual LISP extensions implement ActiveX
and AutoCAD reactor support through AutoLISP, and also provide
ActiveX utility and data conversion functions, dictionary handling
functions, and curve measurement functions.
If the extensions are already loaded, vl-load-com does nothing.
Return Values
Unspecified.
它仍然会留下我提到的信息,但会画出一条线。
李对此有一个答案。 谢谢秃鹰
但什么都没有改变。
还有别的解决办法吗???
当做
迈克尔
确保已将更改保存在lisp中。同时启动新的绘图任务,然后再次加载lisp。
开始Lisp程序,然后出发。
再试一次。 雅哈,没错。
我过去常常直接从Visual Lisp编辑器加载代码,但将其保存为Lisp文件并再次加载则不同,效果更好。
因此绘制了Mline,但正如您前面提到的,代码出现在末尾。
#<VLA-OBJECT IAcadMLine 0cc48984>
这是什么意思????
谢谢
迈克尔
我不确定。正如我所说的,李会回答这个问题。但我相信代码会给你一些想法,如何做自己的,你可以想出如何修改它,以你喜欢的。我相信这是我为mline看到的第一个代码,我觉得它非常有趣。 大家好
我在land desktop2002做一个小项目,
clint提供了jpeg和jgw文件以转换为plines。
请告诉我去connvert的简单方法
欢迎来到论坛,我建议你开始一个新的线程。你会得到更多答案。你的主题与这条线索无关。
祝你好运
页:
[1]
2