Adding text as selected Object Layer name

Adding text as selected Object Layer name

jyan2000
Advocate Advocate
488 Views
2 Replies
Message 1 of 3

Adding text as selected Object Layer name

jyan2000
Advocate
Advocate

Hi, 

How do I add text with selected obeject Layer name? 

 

exp: 

Layer name : Wall Partition_150mm

DText : "Wall Partition_150mm"

 

Regards

Victor

 

0 Likes
489 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

are you using VB.NET or VBA?

Can you show the code you have currently so we so where you have the problems and so where to start?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

jyan2000
Advocate
Advocate

Hello Alfred, 

 

I've found this code, but it doesn’t work. I'd like to edit specific descriptions with TEXT, such as TEXT height (50), TEXT Position (0, 0, 0), TEXT Layer same as Selected Object, TEXT Justify ( M ).

 

Best regards

Victor  

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

(defun rjp-addtext (ins hgt text / doc x)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-addText
(if (= (getvar 'cvport) 1)
(vla-get-paperspace doc)
(vla-get-modelspace doc)
)
text
(vlax-3d-point ins)
(* (getvar 'dimscale) hgt)
)
)


(defun c:test (/ index ss obj lyr ept spt mpt)
(setq index -1)
(if (setq ss (ssget "x" '((0 . "PLINE"))))
(progn
(while (< (setq index (1+ index)) (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss index))
lyr (vla-get-layer obj)
ept (vlax-get obj 'endpoint)
spt (vlax-get obj 'startpoint)
mpt (polar ept (angle ept spt) (/ (distance ept spt) 2.0))
)
(rjp-addtext mpt 1 lyr)
)
(princ)
)
)
(princ)
)

0 Likes