need help with code for changing Visibilty parameter

need help with code for changing Visibilty parameter

acadadmin3KNUF
Advocate Advocate
801 Views
5 Replies
Message 1 of 6

need help with code for changing Visibilty parameter

acadadmin3KNUF
Advocate
Advocate

Hello to all:  

I am trying to change a Visibility Parameter to a specified value for every block in a dwg (1 block attached).  I've found this code from Lee Mac, but I'm not sure where to put in the values I need.  The comment section shows what is what, but I can't figure out where in the code to substitute my specific, needed values.  I've added them as comments below the code.

 

;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(defun POSTSALE ( blk prp val )
    (setq prp (strcase prp))
    (vl-some
       '(lambda ( x )
            (if (= prp (strcase (vla-get-propertyname x)))
                (progn
                    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                    (cond (val) (t))
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)


;;PROPERTY NAME IS: ADMIN_1
;;VALUE TO CHANGE TO IS: 1 ACCS-ON|PWR-ON|FPM-ON

 

There could be up to 150 differently-named blocks in any dwg I have to work with, but they will ALL have that Visibility Parameter and I need to change every block's visibility state to that value in the code.  Can someone tell me where in the code I need to swap out for my needed data?  Thanks in advance for any replies! 

 

0 Likes
Accepted solutions (1)
802 Views
5 Replies
Replies (5)
Message 2 of 6

pbejse
Mentor
Mentor

@acadadmin3KNUF wrote:

....but I'm not sure where to put in the values I need.  

 


(POSTSALE blk "ADMIN_1" "1 ACCS-ON|PWR-ON|FPM-ON")

@acadadmin3KNUF wrote:

 

There could be up to 150 differently-named blocks in any dwg I have to work with, but they will ALL have that Visibility Parameter and I need to change every block's visibility state to that value in the code


(defun c:demo (/ visname VAL SS I EV)
  (setq	visname	"ADMIN_1"
	val	"1 ACCS-ON|PWR-ON|FPM-ON"
  )
  (if (setq ss (ssget "_:L" '((0 . "insert"))))
    (repeat (setq i (sslength ss))
      (setq ev (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (vl-some '(lambda	(dp)
		  (if (and (Eq (vla-get-propertyname dp) visname)
			   (member val (vlax-get dp 'AllowedValues))
		      )
		    (POSTSALE ev visname val)
		  )
		)
	       (vlax-invoke ev 'getdynamicblockproperties)
      )
    )
  )
  (princ)
)

HTH

0 Likes
Message 3 of 6

acadadmin3KNUF
Advocate
Advocate

Thanks very much for the fast reply....but no luck, here's what I get in the ACAD text window:: 

"Position1 X"
"Position1 Y"
"CONV MR TAG POSITION X"
"CONV MR TAG POSITION Y"
"CONV NUM POSITION X"
"CONV NUM POSITION Y"
"CONV ACCS POSITION X"
"CONV ACCS POSITION Y"
"Angle1"
"Origin"
"Distance1"
"Origin"
"BED LENGTH"
"Origin"
"BF"
"Origin"
"CONTROL SIDE"
"Lookup1"
"Lookup2"
"Angle3"
"Origin"
"CONV PWR POSITION X"
"CONV PWR POSITION Y"
"FPM POSITION X"
"FPM POSITION Y"
"Angle4"
"Origin"
"Angle5"
"Origin"
"DistanceLEFT"
"Origin"
"DistanceRIGHT"
"Origin"
"ADMIN_1"
"ADMIN 2"
"ACCS ATT SWITCH"
"POWER ATT SWITCH"
"DistanceMiddle"
"Origin"
"FPM ATT SWITCH"
"Angle6"
"Origin"
"Angle7"
"Origin"
"CONV TOR POSITION X"
"CONV TOR POSITION Y"
"FLOOR OR HANG POSITION X"
"FLOOR OR HANG POSITION Y"
"ROLLER CENTERS"
"Distance4"
"Origin"
"Distance5"
"Origin"
"Lookup7"
"Angle2"
"Origin"
"Lookup8"
"FAKE DISTANCE FOR COATED ROLLERS SWITCH"
"Origin"
"COATED ROLLERS"
"Distance7"
"Origin"
"SERIES AND MATERIAL SWITCH"
"SERIES AND MATERIAL FAKE MOVE DISTANCE"
"Origin"
"NUMBER OF COATED ROLLERS"
"MATERIAL AND SERIES"
"FLOOR VS HANG SUPPORTED"
"FAKE MOVE DISTANCE FOR FLOOR VS HANG"
"Origin" ; error: no function definition: ADMIN_1

 

0 Likes
Message 4 of 6

pbejse
Mentor
Mentor
Accepted solution

@acadadmin3KNUF wrote:

Thanks very much for the fast reply....but no luck, here's what I get in the ACAD text window:: 

..
"Origin" ; error: no function definition: ADMIN_1
...

 


You have to load thePOSTSALE sub from Lee Mac to work

 

Refer to attached admin1.lsp and try again

command: Admin1

 

 

0 Likes
Message 5 of 6

acadadmin3KNUF
Advocate
Advocate

GOT IT!! 😁

 

Thanks very much, yes I understand about the extra function now.  I was pouring over Lee's list of small programs earlier, and couldn't get that last step of linking them together.  Awesome!

0 Likes
Message 6 of 6

pbejse
Mentor
Mentor

@acadadmin3KNUF wrote:

GOT IT!! 😁

 

Thanks very much, 


 

There you go. Glad it helps

 

 

0 Likes