- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dears,
I have a lot of lines that I need a length, like in attached file. At this moment I do it with a vba that put fields in all lines.
The problems:
1) fields makes drawing slow to regen or after I modify line.
2) fields not follow lines slopes and position, if I stretch or move one end point of line. Text must be in middle of line.
So I thinking use reactors .
I tried reactor but I don't have much experience in lisp and I am having problems with persistent reactors, after I close file and open again, load lisp. Reactor not continue persistent.
This is a test that I tried. Works only for one line.
(defun print-align-text ( owner reactor lst / sp ep a d )
(setq sp (vlax-curve-getstartpoint line1))
(setq ep (vlax-curve-getendpoint line1))
(setq a (angle sp ep))
(setq d (distance sp ep))
'(vla-put-textstring mytext (rtos d 2 0))
(vla-put-alignment mytext acalignmentbottomcenter)
(vla-put-textalignmentpoint mytext (vlax-3d-point (mapcar '/ (mapcar '+ sp ep) (list 2.0 2.0 2.0))))
(vla-put-rotation mytext a)
)
(defun c:pp ( / sp ep a d )
(vl-load-com)
(setq line1 (car (entsel "\nSelect line: ")))
(setq texto(car (entsel "\nSelect text: ")))
(setq sp (cdr (assoc 10 (entget line1))))
(setq ep (cdr (assoc 11 (entget line1))))
(setq line1 (vlax-ename->vla-object line1))
(setq mytext(vlax-ename->vla-object texto))
(setq a (angle sp ep))
(setq d (distance sp ep))
(vla-put-alignment mytext acalignmentbottomcenter)
(vla-put-textalignmentpoint mytext (vlax-3d-point (mapcar '/ (mapcar '+ sp ep) (list 2.0 2.0 2.0))))
(vla-put-rotation mytext a)
(setq myreactor (vlr-object-reactor (list line1) "Object Reactor : " '((:vlr-modified . print-align-text))))
(vlr-pers myreactor)
(princ)
)
I have read that is better store data using XData. But I have no idea to start.
In VBA I tried construct class module withevents, without any sucess.
My knowledge in VBA is basic.
Anyone could you give some directions to study best way to do it?
I can't use any kind of dimension.
Thanks
Claudio
Solved! Go to Solution.