SunnyTurtle Posted January 7, 2013 Posted January 7, 2013 I have a lisp that changes the visablity state of a block but i need a lisp that does somthing like descirped: if visablity state = INPUT1 set visablity state to INPUT2 (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
pBe Posted January 8, 2013 Posted January 8, 2013 (vlax-put dp 'Value (strcat "RTA_SCALE_" (substr ans 3))) better yet (member (setq scale (strcat "RTA_SCALE_" (substr ans 3))) (vlax-get dp 'AllowedValues)) (vlax-put dp 'Value scale) HTH Quote
pBe Posted January 8, 2013 Posted January 8, 2013 (edited) I have a lisp that changes the visablity state of a block but i need a lisp that does somthing like descirped: if visablity state = INPUT1 set visablity state to INPUT2 What your describing is easy enough to code. It would better to include the specific Dynamic block name on the ssget filter. So this is how i would play it: Select blocks Retrieve Dynamic properties Get a list of allowed values Choose "what is" Choose "what will" Change visibility EDIT: Like so (defun c:repv (/ _dp ss allowed n el el2 vs vsn blk dp) ;;; pBe 08Jan2013 ;;; (defun _dp (en pn m / vis) (setq vis (car (vl-remove-if-not '(lambda (k) (eq (vla-get-PropertyName k ) pn )) (vlax-invoke en 'GetDynamicBlockProperties)))) (if (and vis m) (vlax-get vis 'AllowedValues) vis)) (Setq same (lambda (f b) (Eq (Strcase (vla-get-effectivename f)) (strcase b)))) (if (and (setq ss (ssget "_:L" '((0 . "INSERT")(2 . "[color="blue"][b]BLOCKNAME[/b][/color],`*U*")))) (same (vlax-ename->vla-object (ssname ss 0)) [b][color="blue"]"BLOCKNAME"[/color][/b]) (setq allowed (_dp (vlax-ename->vla-object (ssname ss 0)) "RMS_SCALE_VIS" t)) (setq n -1) (not (textscr)) (foreach itm allowed (print (list (setq n (1+ n)) itm))) (not (initget 1)) (setq el (getint "\nChoose Visibility to find [index number]: ")) (setq vs (nth el allowed)) (setq el2 (getint (strcat "\nChoose Visibility for " vs " [index number]: "))) (setq vsn (nth el2 allowed)) ) (repeat (setq i (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (cond ((and (same blk "BLOCKNAME") (setq dp (_dp blk "RMS_SCALE_VIS" nil)) (eq (vlax-get dp 'Value) vs) (vlax-put dp 'value vsn) ) ) ) ) )(princ) ) Or even an easier way. Select blocks Get a list of allowed values Choose visibilty property to find (sssetfirst nil sset) Then use Properties to change visiblity Almost same as above except we will use (sssetfirst nil coll) HTH Edited January 8, 2013 by pBe Quote
SunnyTurtle Posted January 16, 2013 Author Posted January 16, 2013 Thanks i will have to look in to this a bit more But the descriptions are very useful. Thanks for your help Quote
pBe Posted January 17, 2013 Posted January 17, 2013 Thanks i will have to look in to this a bit moreBut the descriptions are very useful. Thanks for your help Glad to be of service, keep us posted SunnyTurtle Quote
BlackBox Posted January 17, 2013 Posted January 17, 2013 FWIW - http://www.cadtutor.net/forum/showthread.php?61221-Dynamic-block-counting!&p=415884&viewfull=1#post415884 Quote
pBe Posted January 17, 2013 Posted January 17, 2013 FWIW - http://www.cadtutor.net/forum/showthread.php?61221-Dynamic-block-counting!&p=415884&viewfull=1#post415884 Nice linky Renderman. I gave up long ago trying to find a way to capture the "visibilty" paramater name Now that i've seen how its done. bookmarks.. click.. click Thank you for that Quote
Lee Mac Posted January 17, 2013 Posted January 17, 2013 I gave up long ago trying to find a way to capture the "visibilty" paramater name Now that i've seen how its done. The Visibility Parameter will not necessarily be called "Visibility.." Quote
pBe Posted January 17, 2013 Posted January 17, 2013 The Visibility Parameter will not necessarily be called "Visibility.." Thats exactly what i mean, thats why i enclosed the word visibility with a double quote to remind others that its not always named "visibility" and read RM's linky. Sorry for the confusion LM Quote
Lee Mac Posted January 17, 2013 Posted January 17, 2013 Thats exactly what i mean, thats why i enclosed the word visibility with a double quote to remind others that its not always named "visibility" and read RM's linky. Sorry for the confusion LM Oh right - sorry for the confusion - for what its worth, this is what I use. Cheers! Quote
pBe Posted January 17, 2013 Posted January 17, 2013 ..... for what its worth, this is what I use. Cheers! Yup, that is the code i was referring to (at the end of the thread). The thread is a good read for all. lots of info. Cheers! Quote
BlackBox Posted January 17, 2013 Posted January 17, 2013 I gave up long ago trying to find a way to capture the "visibilty" paramater name Now that i've seen how its done. The Visibility Parameter will not necessarily be called "Visibility.." Thats exactly what i mean, thats why i enclosed the word visibility with a double quote to remind others that its not always named "visibility" and read RM's linky. Sorry for the confusion LM Oh right - sorry for the confusion - for what its worth, this is what I use. Cheers! ... Perhaps I am to blame for the confusion here; if memory serves, it was you, Lee, that corrected my earlier assumption (at the time the linked code was posted) to this same point somewhere later in that thread. Knowing that I needed to be educated to this point back then (again, thank you, Lee), I should have done others the courtesy of at least finding, and linking to that post of yours as well. Quote
BlackBox Posted January 17, 2013 Posted January 17, 2013 Knowing that I needed to be educated to this point back then (again, thank you, Lee), I should have done others the courtesy of at least finding, and linking to that post of yours as well. [self Fulfilling Prophecy] Renderman, A tip: AFAIK, the first dynamic block property is not always going to be the Visibility State. Note that a Visibility State property may not always be called 'Visibility', or even contain that phrase. :wink: [\ Self Fulfilling Prophecy] Quote
Lee Mac Posted January 17, 2013 Posted January 17, 2013 Sorry for all the confusion guys - The original link was to a specific post, so I had automatically assumed that subsequent posts in this thread were referring to that linked post, and hence wanted to clarify any assumptions about the Visibility Parameter name... Thank you for your time pBe & RenderMan Quote
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.