创建匿名组
(defun isAppLoaded (app)(if (not (member app (arx)))
(setq bAppLoaded :vlax-false)
(setq bAppLoaded :vlax-true)
)
bAppLoaded
)
(defun Example采用AddLightWeightPolyline()
(vl-load-com)
(if (= (isAppLoaded "asdkanonygrplsp.arx") :vlax-false)
(arxload (findfile "asdkanonygrplsp.arx"))
)
(setq oAcad (vlax-get-acad-object)
oDoc (vla-get-activedocument oAcad)
*ModelSpace* (vla-get-ModelSpace oDoc)
)
;;Add anonymous group
(setq myGroup (vl-catch-all-apply
'vla-objectidtoobject
(list
oDoc
(vlax-make-variant
(car (acdbAddAnonGrpRet2Lsp))
vlax-vbLong
)
)
)
) ;setq
;;If error encountered making group, then exit
(if (vl-catch-all-error-p myGroup)
(princ (vl-catch-all-error-message myGroup))
;;otherwise continue...
(progn
;; Define the 2D polyline points
(setq pt1 (list 1.0 1.0)
pt2 (list 1.0 2.0)
pt3 (list 2.0 2.0)
pt4 (list 3.0 2.0)
pt5 (list 4.0 4.0)
)
(setq Points (apply 'append (list pt1 pt2 pt3 pt4 pt5)))
(setq ptlstlen (length Points))
;; Make array of 5*2=10 doubles -
;; that's an array of dimension 0 to 9
(setq PointDataA (
vlax-make-safearray vlax-vbDouble (
cons 0 (1- ptlstlen))))
(vlax-safearray-fill PointDataA Points)
(setq PointData (vlax-make-variant PointDataA))
;; Create a light weight Polyline object in model space
(setq myLWpoly (
vla-addLightweightPolyline *ModelSpace* PointData))
;; Make array of 1 object (the new LWPolyline)
(setq myObjA (vlax-make-safearray vlax-vbObject '(0 . 0)))
(vlax-safearray-put-element myObjA 0 myLWpoly)
;; Add the LWPolyline to the group
(vla-appenditems myGroup myObjA)
) ;progn
) ;if
(princ)
)
页:
[1]