MUTHUKUMAR1983 Posted April 2, 2024 Posted April 2, 2024 here i try this code not change correctly (defun C:chvis (/ ss i blk curVis newVis) (if (setq ss (ssget "_:L" '((0 . "INSERT")))) (progn (repeat (setq i (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (and (= "AcDbBlockReference" (vla-get-ObjectName blk)) (= :vlax-true (vla-get-IsDynamicBlock blk))) (progn (setq curVis (LM:getdynpropvalue blk "visibility")) (setq newVis (cond ((= "1" curVis) "2") ((= "2" curVis) "3") ((= "3" curVis) "4") ((= "4" curVis) "1") (t (progn (prompt "\nUnknown visibility value, setting to 1.") "1")) ; Default to 1 if visibility is unknown )) (LM:setdynpropvalue blk "visibility" newVis) ) ) ) ) ) (princ) ) ;; Set Dynamic Block Property Value ;; 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 LM:setdynpropvalue (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)))) val ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Get Dynamic Block Property Value ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; Returns: [any] Value of property if found, else nil (defun LM:getdynpropvalue (blk prp) (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (vla-get-value x) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) (vl-load-com) (princ) visibility.dwg Quote
BIGAL Posted April 2, 2024 Posted April 2, 2024 My take on problem, I have saved Lee's dynamic block lisp as per name below, rather than having defuns in code, makes sure I get all defuns that are required, sometimes functions call another function in Lee's code Dynamic block get-put-part2.lsp 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.