Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP not working

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
john-B
614 Views, 3 Replies

LISP not working

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

3 REPLIES 3
Message 2 of 4
alexeispirit
in reply to: john-B

(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.

Message 3 of 4
pbejse
in reply to: john-B

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

 

 

 

 

Message 4 of 4
john-B
in reply to: alexeispirit

Thank you gentlemen.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost