Hi all
I'm trying to run a lisp file as below:
(defun c:CleanDefpoints (/ nplotLayer blk eo)
(vl-load-com)
;; Get ActiveX objects as global variables (if not already done so)
(or *vla-Acad-Object* (setq *vla-Acad-Object* (vlax-get-acad-object)))
(or *vla-ActiveDocument* (setq *vla-ActiveDocument* (vla-get-ActiveDocument *vla-Acad-Object*)))
(or *vla-BlocksCollection* (setq *vla-BlocksCollection* (vla-get-Blocks *vla-ActiveDocument*)))
(or *vla-LayersCollection* (setq *vla-LayersCollection* (vla-get-Layers *vla-ActiveDocument*)))
;; Check if non-plot layer exists
(setq nplotLayer "NoPlot") ;Change name to suit
(if (or
;; If the layer exists
(not (vl-catch-all-error-p (setq eo (vl-catch-all-apply 'vla-Item (list *vla-LayersCollection* nplotLayer)))))
;; Or can be created
(setq eo (vla-Add *vla-LayersCollection* nplotLayer))
)
(progn
;; Turn its Plottable property OFF
(vla-put-Plottable eo :vlax-false)
;; Step through everything in this drawing and change it from Defpoints to the non-plot layer
(vlax-for blk *vla-BlocksCollection*
(if (and (= (vla-get-IsXRef blk) :vlax-false) ;If the current block def is not an xref
(wcmatch (vla-get-EffectiveName blk) "~`*D*") ;And is not unnamed blockdef of dimension
)
;; Step through all entities inside the block
(vlax-for eo blk
(if (eq (strcase (vla-get-Layer eo)) "DEFPOINTS") ;Check if entity is on defpoints
(vla-put-Layer eo nplotLayer)
)
)
)
)
)
)
(princ) )
BUT I keep getting the following erroe message:- ; error: ActiveX Server returned the error: unknown name: EffectiveName
Can anyone out there tell me how to get this lisp workng properly.
I do not know the author of the file.
Regards John-b
Solved! Go to Solution.
Solved by alexeispirit. Go to Solution.
(defun c:CleanDefpoints (/ nplotLayer blk eo) (vl-load-com) ;; Get ActiveX objects as global variables (if not already done so) (or *vla-Acad-Object* (setq *vla-Acad-Object* (vlax-get-acad-object))) (or *vla-ActiveDocument* (setq *vla-ActiveDocument* (vla-get-ActiveDocument *vla-Acad-Object*))) (or *vla-BlocksCollection* (setq *vla-BlocksCollection* (vla-get-Blocks *vla-ActiveDocument*))) (or *vla-LayersCollection* (setq *vla-LayersCollection* (vla-get-Layers *vla-ActiveDocument*))) ;; Check if non-plot layer exists (setq nplotLayer "NoPlot") ;Change name to suit (if (or ;; If the layer exists (not (vl-catch-all-error-p (setq eo (vl-catch-all-apply 'vla-Item (list *vla-LayersCollection* nplotLayer))))) ;; Or can be created (setq eo (vla-Add *vla-LayersCollection* nplotLayer))) (progn ;; Turn its Plottable property OFF (vla-put-Plottable eo :vlax-false) ;; Step through everything in this drawing and change it from Defpoints to the non-plot layer (vlax-for blk *vla-BlocksCollection* (if (and (= (vla-get-IsXRef blk) :vlax-false) ;If the current block def is not an xref (wcmatch (vla-get-Name blk) "~`*D*")) ;And is not unnamed blockdef of dimension ;; Step through all entities inside the block (vlax-for eo blk (if (eq (strcase (vla-get-Layer eo)) "DEFPOINTS") ;Check if entity is on defpoints (vla-put-Layer eo nplotLayer))))))) (princ))
You should use 'Name instead of 'EffectiveName with Block object. EffectiveName is a BlockReference property only.
AcDbBlockTableRecord (*vla-BlocksCollection*) objects doesnt have Effectivename propoerty.
Also it generates an error when: blk is a layout object
(and (= (vla-get-IsXRef blk) :vlax-false) ;If the current block def is not an xref
(eq :vlax-false (vla-get-isLayout blk))
(wcmatch (vla-get-Name blk) "~`*D*") ;And is not unnamed blockdef of dimension
)
That is if you want to edit Blocks only
(and (= (vla-get-IsXRef blk) :vlax-false) ;If the current block def is not an xref
(wcmatch (vla-get-Name blk) "~`*D*") ;And is not unnamed blockdef of dimension
)
Would process all entiteis except XREF
HTH