mbrandt5 Posted November 10, 2015 Share Posted November 10, 2015 (vl-load-com) ;Loads ActiveX ;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------; ; LINE PREDEFINED ; ; This Function predefines a line by its object handle/ObjID ; ; ; ; ; ;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------; (defun C:line-predefined () ;Defines Predefined Line (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) ; Set Equal AcadDocument to Active Document in Acad (setq mspace (vla-get-modelspace acadDocument)) ; Set Equal MSpace to Mspace in AcadDocument (setq ename-line (handent "10BE")) ; Set Equal Ename-line to Entity Name Of Handle "10BE" (setq vlaobject-line (vlax-ename->vla-object ename-line)) ; Set Equal Vlaobject-line to VLA Object of Ename-line (setq ename-mtext (handent "10D1")) ; Set Equal Ename-mtext to Entity Name Of Handle "10D1" (setq vlaobject-mtext (vlax-ename->vla-object ename-mtext)) ; Set Equal Vlaobject-mtext to VLA Object of Ename-mtext (setq lineReactor (vlr-object-reactor (list vlaobject-line) "Line Reactor" '((:vlr-modified . print-length)) ) ) ; Set Equal lineReactor to vla-object-reactor for vla-object-line that executes print-length (princ) ; Exit Quietly ) ;defun ;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------; ; PRINT LENGTH TO MTEXT CONTENTS ; ; This Function prints the length of a line predefined by its object handle/ObjID ; ; To the contents of a predefined Mtext Object ; ; ; ;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------; (defun print-length (notifier-object reactor-object parameter-list) (If (cond ((vlax-property-available-p vlaobject-mtext "Contents") (vlax-put-property vlaobject-mtext (vlax-property-available-p notifier-object "Length") ) ) ((vlax-property-available-p notifier-object "Length") ; Checks if property "Length" of notifier-object (vlaobject-line) is avaible to edit (vl-string-subst "ReplaceMe" "Ben" "") ) ) ;cond ) (princ) ; Exit Quietly ) ;defun (princ) ; Exit Quietly I'm looking to have a lisp that when vlaobject-lines property length is modified it will add that length as a string to the contents property of vlaobject-mtext In the end I'd like to replace just a part of the text string that makes up the contents of vlaobject-mtext like so replacing YYY with "Length Mtext Old Contents = 3/8"x7" x YYY Mtext New Contents = 3/8"x7" x "Length" I'm only having trouble with the print-length function, I believe The drawing with the predefined objects, and the lisp are attached If anyone could help me I would greatly appreciate it... LineMtextReactorV1.lsp linetest.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 10, 2015 Share Posted November 10, 2015 I think the field command should help you with it and there is no need for a reactor. Quote Link to comment Share on other sites More sharing options...
mbrandt5 Posted November 10, 2015 Author Share Posted November 10, 2015 It's for a dynamic block that is severely slowed down by attributes containing fields.... So I'm doing this as a substitute for a field... Also the field requires refreshing/field updating while a reactor would not require such... So in my circumstance there is a need for a reactor. Unfortunately lol Quote Link to comment Share on other sites More sharing options...
mbrandt5 Posted November 10, 2015 Author Share Posted November 10, 2015 Though I find it a good learning experience Quote Link to comment Share on other sites More sharing options...
mbrandt5 Posted November 10, 2015 Author Share Posted November 10, 2015 Apparently I can use fields in mtext if they're object fields oops thanks thwart Quote Link to comment Share on other sites More sharing options...
mbrandt5 Posted November 16, 2015 Author Share Posted November 16, 2015 Okay so actually I would still like to see this work if anyone can tell me what I'm doing wrong...I just can't seem to figure it out... I'd like in the end to have to predefined lines that the larger of the two trump the other and is then denoted in the mtext Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.