Jump to content

LineDistance To Mtext Reactor


mbrandt5

Recommended Posts

(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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...