TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on December 12, 2008, 09:46:42 PM
-
This is my very rough draft of a routine similar to Tim's Area Reactor Routine. The idea here is
to have a line with a reactor to update plain text with the length. I had pipe lengths in mind when
I started this. This is only my 3rd or 4th reactor routine so I borrowed ideas and code as usual.
The routine is somewhat tested but is still early in the development so beware. It adds FT to the
text string so metric will be in a later release.
This is an Object reactor and is non-persistent although it will act like a persistent reactor if you
load and run the lisp.
Just looking for feed back at this point.
This is the header info:
This routine creates & maintains reactors attached to a line object with an associated
text object that contains the length of the line. The text is placed at the center of the line
and rotated to the angle of the line. Text should be plain text with middle Center justification.
Non-persistent reactors are lost when the DWG closes. Persistent reactors are
not lost but will not function when the DWG is opened unless the call back
routine is loaded. Therefore to have them act like persistent reactors by saving
a list of objects & there associated objects in the DWG. I think xData
attached to the Document or another dictionary or item like Layer "0" that will not
be lost is the best way. Ldata is reported to be unreliable at times.
When the DWG is opened a routine should run to restore the reactors. If any were
deleted then remove them from the list.
A 'remove reactor' routine should include removing it from the xData list.
If an item was erased, the link should be left in the xData list in case it is unerased.
An unErase CMD reactor routine will be needed to restore any objects erased in this session.
Need to verify the erase destroys the reactor connection.
Thanks to Tim Willey for some of the code from his Area Reactor routine.
Thanks to Luis for his idea to emulate persistent reactors.
To start the reactors when you open a drawing where the reactors have been creatred
load this lisp & run this function (LengthReactorStartup)
To set up reactors enter LengthReactor at the command line
<edit: Replaced lisp>
-
Alan
Why not use an associative dimension with only text showing (no lines or ticks)?
-
Gary,
This is as usual for me, an exercise in using Object reactors. I chose length of line because I have a need
for length & size of a pipe to be set & retrieved. It could be expanded to ducts or conduit as well when
I get it working properly. 8-)
-
Found a bug or two in the start-up routine so I updated the code.
Also added some reporting.
-
Gary,
This is as usual for me, an exercise in using Object reactors. I chose length of line because I have a need
for length & size of a pipe to be set & retrieved. It could be expanded to ducts or conduit as well when
I get it working properly. 8-)
Go for it... Alan.
When I did/wrote my stuff about reactors, that help me a lot to learn more about programming.
If helps, there is a project DIMXL - DIMPOLY - that I posted here, that could be handy.
Regards,
Luis.
-
Thanks Luis, I'll check them out.
-
Thanks Luis, I'll check them out.
I tested your routine, and looks that it is working.... so you are in the right track. :)
-
Thanks you sir, more to come. :)
I need to add a user pick to the remove reactor.
-
Updated the Routine. 12/14/2008 Version 1.3
Bug fix & cleaned up some of the code.
Also added some notes.
More work needed.
-
awesome!!!
CAB, You, good man!
I have set myself to learn from you!
pay my respects to you! :-)
-
Thanks cjw,
I'm learning my self. :-)
-
Seems to work good here also Alan. I noticed that the text will always move to the same spot when you modify the line object, but you can move the text object by itself, and it won't relocate until you modify the line object. Just something I noticed.
Also you might have to release the reactor object, as it is still there when you erase the text object and then modify the line object. The erased object ( in the quoted command section below ) is the text object, and then the stretch command is applied to the same line object each time. Notice that the reactor is still firing eventhough there is no reactor returned by the function ' AssociatedReators '.
Command: e ERASE
Select objects: Specify opposite corner: 1 found
Select objects:
Command: Specify opposite corner:
Command:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]:
Reactor has be removed because the text object has been erased.
Command:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]:
Reactor has be removed because the text object has been erased.
Command:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]:
Reactor has be removed because the text object has been erased.
Command:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]:
Reactor has be removed because the text object has been erased.
Command: (AssociatedReactors (vlax-ename->vla-object (car (entsel))))
Select object: nil
Command:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]:
Reactor has be removed because the text object has been erased.
-
I couldn't find how to release a transient reactor, but this change will not show the message anymore.
(defun AdjustTextObj (Obj reactor-object parameter-list / my-data TextObj)
(setq my-data (vlr-data reactor-object)) ; '("MyLengthReactorModified" TextObj)
(if (and (= (car my-data) "MyLengthReactorModified")
(not (vlax-erased-p Obj))
)
(if (and (setq TextObj (cadr my-data))
(not (vlax-erased-p TextObj))
)
(PutLength Obj TextObj)
[color=red](if (vlr-remove reactor-object) ; turn reactor off
(prompt "\n Reactor has be removed because the text object has been erased.")
)[/color]
)
)
)
-
Thanks Tim, I'll look into it tomorrow.
Been out most of the evening and I'm out of gas. :-P