Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/01/2019 in all areas

  1. Assuming that I've correctly understood what you are looking to achieve, you could define a basic dynamic attributed block containing a single attribute to display the distance, and a rotation parameter with a rotate action assigned to the arrow symbol within the block. Then, you can use a program to automatically insert the block, populate the attribute, and configure the dynamic block parameter appropriately: To offer an example to demonstrate this in action, try using the following code in conjunction with the attached dynamic block: (defun c:bb ( / ang blk bln dis ins obj pt1 pt2 scl ) (setq bln "TEST" ;; Block name dis "DIS" ;; Distance attribute tag ang "ANG" ;; Rotation parameter name scl 1.0 ;; Block scale ) (cond ( (not (setq blk (LM:importblock bln))) (princ (strcat "\nThe block \"" bln "\" was not found or could not be defined.")) ) ( (and (setq pt1 (getpoint "\nSpecify 1st point of bearing: ")) (setq pt2 (getpoint "\nSpecify 2nd point of bearing: " pt1)) (setq ins (getpoint "\nSpecify block insertion point: ")) ) (setq obj (vla-insertblock (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace) ) (vlax-3D-point (trans ins 1 0)) blk scl scl scl (angle '(0 0) (trans (getvar 'ucsxdir) 0 (trans '(0 0 1) 1 0 t) t)) ) ) (LM:vl-setattributevalue obj dis (rtos (distance pt1 pt2) 2 0)) (LM:setdynpropvalue obj ang (angle pt1 pt2)) ) ) (princ) ) ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val) ) ) (vlax-invoke blk 'getattributes) ) ) ;; 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 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)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ;; Import Block Definition - Lee Mac ;; blk - [str] Block name, drawing filename, or full filepath ;; Returns: [str] Block name if successful, else nil (defun LM:importblock ( blk / bse cmd ext pth ) (setq pth (vl-string-translate "/" "\\" (vl-filename-directory blk)) ext (cond ((vl-filename-extension blk)) (".dwg")) bse (vl-filename-base blk) ) (if (not (or (= "" pth) (wcmatch pth "*\\"))) (setq pth (strcat pth "\\")) ) (cond ( (tblsearch "block" bse) bse) ( (setq blk (findfile (strcat pth bse ext))) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.-insert" blk nil) (setvar 'cmdecho cmd) (if (tblsearch "block" bse) bse ) ) ) ) (vl-load-com) (princ) The above uses existing functions from my Attribute Function library and Dynamic Block Function library. test.dwg
    1 point
×
×
  • Create New...