Dimension Measure to ATT

Dimension Measure to ATT

duynhat151092
Participant Participant
315 Views
1 Reply
Message 1 of 2

Dimension Measure to ATT

duynhat151092
Participant
Participant

Hello everyone, I have a pretty interesting Lisp that extracts the value from a DIM and inserts it into text or Mtext as a field.

But now I want to insert it into an ATT of any block.

Can anyone help me with this?

Thank you very much.

I have attached the code.

Best regards.

 

 

;; ObjectID  -  Lee Mac
;; Returns a string containing the ObjectID of a supplied VLA-Object
;; Compatible with 32-bit & 64-bit systems
(defun LM:objectid ( obj )
    (eval
        (list 'defun 'LM:objectid '( obj )
            (if (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                (if (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
                    (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
                   '(LM:ename->objectid (vlax-vla-object->ename obj))
                )
               '(itoa (vla-get-objectid obj))
            )
        )
    )
    (LM:objectid obj)
)

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object
(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)
 

(defun c:dimF (/ ent dtxt)
  (vl-load-com)
  (and (setq ent (car (entsel "\nSelect Dimension: ")))
       (eq "DIMENSION" (cdr (assoc 0 (entget ent))))
       (setq dtxt (car (entsel "\nSelect Destination: ")))
       (wcmatch (cdr (assoc 0 (entget dtxt))) "*TEXT,MULTI*")
       (vla-put-TextString
         (vlax-ename->vla-object dtxt)
           
           (strcat
             "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Measurement \\f \"%lu2%pr2\">%")))

  (princ))

0 Likes
316 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

Replace part of code with this.

 

(setq dtxt (car (nentsel "\nSelect attribute : ")))
(vla-put-TextString
  (vlax-ename->vla-object dtxt)
  (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%).Measurement \\f \"%lu2%pr2\">%")
)
0 Likes