Finally got the whole thing working!!!!
This command does the following:
- Creates a layer for the detail bubble
- Creates a layer for the callout tag
- Draws the detail bubble based on two picked points
- Sets the width and fillet radius of the rectangle according to the current annotation scale (so it always reads 1/16" wide with 5/8" fillets radii - in this case)
- sets OSMODE to Midpoint/Endpoint
- Inserts the callout block
- Sets the Visibility of the callout block to "None" (no arrowhead)
- Sets the current layer and OSMODE back to what they were when we started.
Here it is:
Code:
(defun C:ADB( / CL COSM FRAD CAS NHS PLW)
;;;;; Collect current layer, and OSMODE settings
(setq CL (getvar "CLAYER"))
(setq COSM (getvar 'osmode))
;;;;; Set OSPMODE to ENDPOINT and MIDPOINT only
(setvar 'osmode 4131)
;;;;; Collect current annotation scale value and create Values for POLYLINE WIDTH width and FILLET RADIUS
(setq CAS (getvar 'cannoscalevalue))
(setq NHS (/ 1 CAS))
(setq PLW (* NHS 0.0625))
(setq FRAD (* 10 PLW))
;;;;; Creat layer for the detail box and make it current
(command "_.-Layer" "m" "L-DTL-BOX" "c" "5" "L-DTL-BOX" "l" "DASHED" "L-DTL-BOX" "")
(setvar 'CLAYER "L-DTL-BOX")
;;;;; Draw the box using pline width and fillet radius values
(command "_.rectang" "_f" FRAD (while (> (getvar 'CmdActive) 0) (command pause)))
(command "_.PEDIT" "L" "L" "on" "w" PLW "")
(command "_.rectang" "_f" "0")
(command)
;;;;; Create the layer fo the detail tag and make it current
(command "_.-Layer" "m" "L-ANNO-SYMB" "c" "3" "L-ANNO-SYMB" "")
(setvar 'CLAYER "L-ANNO-SYMB")
;;;;; Bring in block Detail Callout IMP r03 block from MVVA Callouts_Imperial r01.dwg
(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")
;;;;; Retuen current layer and OOMODE to original values
(setvar 'CLAYER CL)
(setvar 'OSMODE COSM)
;;;;; change visibility state of Detail Callout IMP r03 block to "None"
(defun 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))
)
)
)
(CHGDYNPROP (entlast) "Visibility1" "None") ;none is the visibility state name
(princ)
)