Author Topic: CHGDYNPROP not working in LISP routine  (Read 1844 times)

0 Members and 1 Guest are viewing this topic.

jpcadconsulting

  • Newt
  • Posts: 56
CHGDYNPROP not working in LISP routine
« on: November 05, 2014, 01:53:14 PM »
Hi gang,

I've cobbled together a lisp routine that will draw a detail bubble, and add a tag that is a dynamic block.  It works absolutely fine except is does not change the visibility state of the inserted block.  No errors, it just fails to change the Visibility state.

Any help is appreciated.

Code: [Select]
(defun C:TESTBUB2( / TMP CAS NHS PLW)
(setvar "CMDECHO" 0)
(setq CL (getvar "CLAYER"))
(setq CAS (getvar 'cannoscalevalue))
(setq NHS (/ 0.625 CAS))
(setq PLW (/ NHS 10))
(command "_.-Layer" "m" "L-DTL-BOX" "c" "5" "L-DTL-BOX" "l" "DASHED" "L-DTL-BOX" "")
(command "_.rectang" "_f" NHS (while (> (getvar 'CmdActive) 0) (command pause)))
(command "_.PEDIT" "L" "L" "on" "w" PLW "")
(command "_.rectang" "_f" "0")
(command)
(command "_.-Layer" "m" "L-ANNO-SYMB" "c" "3" "L-ANNO-SYMB" "l" "CONTINUOUS" "L-ANNO-SYMB" "")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Bring Detail Callout IMP r03 block into drawing ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun open_dbx (dwg / dbx)
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq dbx (vlax-create-object
(strcat "ObjectDBX.AxDbDocument."
(substr (getvar "ACADVER") 1 2)
)
)
)
)
(vla-open dbx dwg)
dbx
)
(setq Dbx (open_dbx "//ny-fs01/cad_common$/AutoCAD 2014/Drawings/MVVA Callouts_Imperial r01.dwg"))
(vla-CopyObjects
Dbx
(vlax-safearray-fill
(vlax-make-safearray vlax-vbObject '(0 . 0))
(list (vla-item (vla-get-blocks dbx) "Detail Callout IMP r03"))
)
(vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
)
(vlax-release-object dbx)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Insert Detail Callout IMP r03 block ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(command ".-insert" "Detail Callout IMP r03" PAUSE "1" "1" "0")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; change visibility state of Detail Callout IMP r03 block ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    (defun c:CHGDYNPROP (Ename propname newval /  LO obj v vval sal tot i)
       ;; Changes a given variable in your block
       ;; Passed: Ename, Property Name, New value for Property
       ;;
       (setq obj (if (= (type Ename) 'vla-object)
    Ename
    (vlax-ename->vla-object Ename))
     v (vla-getdynamicblockproperties obj)
     vval (vlax-variant-value v)
     sal (vlax-safearray->list vval)
     tot (length sal)
     i 0)
       (while (< i tot)
         (if (= (vlax-get-property (nth i sal) "PropertyName") propname)
           (progn
             (vlax-put-property (nth i sal) "Value" newval)
             (setq i tot)
           )
           (setq i (1+ i))
         )
       )
     )
(setq LO (entlast))
(CHGDYNPROP LO "Visibility" "None")

(setvar "CLAYER" CL)
(princ)
)
Technology will save us all! *eyeroll*