Jump to content

lisp to change visablite state of a dynamic block


SunnyTurtle

Recommended Posts

(defun c:demo (/ ss ans i blk dp)
 	(if 	(and (setq ss (ssget "_:L" '((0 . "INSERT"))))
	     (not (initget 1 "circle square "))
  	     (setq ans (getkword "\nChoose Visibility [circle/square]: ")))
       	(repeat (setq i (sslength ss))
	  	(setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
	  	(cond [b][color="blue"]([/color][/b](and
			   (eq (vla-get-IsDynamicBlock blk) :vlax-true)
		       	   (setq dp (car
				    (vl-remove-if-not
				      '(lambda (k)
					 (eq
					   (vla-get-PropertyName
					     k
					   )
					   [b][color="blue"]"Visibility1"[/color][/b]
					 )
				       )
				      (vlax-invoke
					blk
					'GetDynamicBlockProperties
				      )
				    )
				  )
			   )
		       	(vlax-put dp 'Value ans)
		        )
		      )[b][color="blue"])[/color][/b]
	  )
  )
(princ)
 )

Edited by pBe
Link to comment
Share on other sites

Hi im am having problem running the lisp it seems to fail at the line (LAMBDA (K) (EQ (vla-get-PropertyName K) * "Visibility1" *))

 

when i run the script i get this error: AutoLISP error - too many arguments

Link to comment
Share on other sites

Hi im am having problem running the lisp it seems to fail at the line (LAMBDA (K) (EQ (vla-get-PropertyName K) * "Visibility1" *))

 

when i run the script i get this error: AutoLISP error - too many arguments

 

Not sure where you get that "*" on the lambda function , besides i was missing a pair of parenthesis.

 

"Visibility1" is the visibility parameter name on your DBlock. This code wont do a thing if the name does not match.

Link to comment
Share on other sites

Thanks i remove

*'s and it worked

as i just copyed in to visual lisp editor.

 

Thankyou so much for your help i was having trouble with a lisp of mine and this code will be easy to modify and add to my lisp

Edited by SunnyTurtle
more thanks
Link to comment
Share on other sites

Thanks i remove

*'s and it worked

as i just copyed in to visual lisp editor.

 

Thankyou so much for your help i was having trouble with a lisp of mine and this code will be easy to modify and add to my lisp

 

Good for you, glad it helps :)

Link to comment
Share on other sites

  • 1 month later...

I have create a new Thread with a related question

 

Here is my code as of today

(defun c:set1 (/ ss ans i blk dp scale)
 
 (if (and (setq ss (ssget "_:L" '((0 . "INSERT"))))
     (not (initget 1 "1:1 1:2 1:2.5 1:5 1:10 1:20 1:25 1:50 1:100 1:200 1:250 1:500 1:1000 1:2000 1:2500 1:5000 1:50000 "))
  (setq ans (getkword "\nChoose Visibility [1:1/1:2/1:2.5/1:5/1:10/1:20/1:25/1:50/1:100/1:200/1:250/1:500/1:1000/1:2000/1:2500/1:5000/1:50000]: ")
   ))
  
 (repeat (setq i (sslength ss))  
    (setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
    (cond (and
      (eq (vla-get-IsDynamicBlock blk) :vlax-true)
             (setq dp (car
        (vl-remove-if-not
          '(lambda (k)
      (eq
        (vla-get-PropertyName
          k
        )
        "RMS_SCALE_VIS"
      )
           )
          (vlax-invoke
     blk
     'GetDynamicBlockProperties
          )
        )
      )
      )
         (if (eq ans "1:1") (setq scale "RTA_SCALE_1"))
                (if (eq ans "1:2") (setq scale "RTA_SCALE_2"))
         (if (eq ans "1:2.5") (setq scale "RTA_SCALE_2.5"))
         (if (eq ans "1:5") (setq scale "RTA_SCALE_5"))
         (if (eq ans "1:10") (setq scale "RTA_SCALE_10"))
         (if (eq ans "1:20") (setq scale "RTA_SCALE_20"))
         (if (eq ans "1:25") (setq scale "RTA_SCALE_25"))
         (if (eq ans "1:50") (setq scale "RTA_SCALE_50"))
         (if (eq ans "1:100") (setq scale "RTA_SCALE_100"))
         (if (eq ans "1:200") (setq scale "RTA_SCALE_200"))
         (if (eq ans "1:500") (setq scale "RTA_SCALE_500"))
         (if (eq ans "1:1000") (setq scale "RTA_SCALE_1000"))
         (if (eq ans "1:2000") (setq scale "RTA_SCALE_2000"))
         (if (eq ans "1:2500") (setq scale "RTA_SCALE_2500"))
         (if (eq ans "1:5000") (setq scale "RTA_SCALE_5000"))
         (if (eq ans "1:50000") (setq scale "RTA_SCALE_50000"))
          (vlax-put dp 'Value scale)
          )
        )
   )
 )
 )
 (princ)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...