SunnyTurtle Posted November 20, 2012 Share Posted November 20, 2012 Hi was trying to create a lisp that would change the visablity state of this block if it was inserted into a drawing can anyone help test.dwg Quote Link to comment Share on other sites More sharing options...
pBe Posted November 20, 2012 Share Posted November 20, 2012 (edited) (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 November 22, 2012 by pBe Quote Link to comment Share on other sites More sharing options...
SunnyTurtle Posted November 21, 2012 Author Share Posted November 21, 2012 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted November 22, 2012 Share Posted November 22, 2012 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. Quote Link to comment Share on other sites More sharing options...
SunnyTurtle Posted November 22, 2012 Author Share Posted November 22, 2012 (edited) 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 November 22, 2012 by SunnyTurtle more thanks Quote Link to comment Share on other sites More sharing options...
pBe Posted November 22, 2012 Share Posted November 22, 2012 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 Quote Link to comment Share on other sites More sharing options...
SunnyTurtle Posted January 7, 2013 Author Share Posted January 7, 2013 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.