Jump to content

How to change Visibility change automaticaly one to other


MUTHUKUMAR1983

Recommended Posts

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

Link to comment
Share on other sites

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

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...