Author Topic: Length Reactor  (Read 3988 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Length Reactor
« 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>
« Last Edit: December 14, 2008, 11:41:24 PM by CAB »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1990
Re: Length Reactor
« Reply #1 on: December 13, 2008, 09:12:15 AM »
Alan

Why not use an associative dimension with only text showing (no lines or ticks)?
« Last Edit: December 13, 2008, 09:18:21 AM by GDF »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #2 on: December 13, 2008, 11:14:37 AM »
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-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #3 on: December 13, 2008, 11:14:05 PM »
Found a bug or two in the start-up routine so I updated the code.
Also added some reporting.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Length Reactor
« Reply #4 on: December 14, 2008, 12:07:53 PM »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #5 on: December 14, 2008, 06:44:01 PM »
Thanks Luis, I'll check them out.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Length Reactor
« Reply #6 on: December 14, 2008, 07:35:30 PM »
Thanks Luis, I'll check them out.

I tested your routine, and looks that it is working.... so you are in the right track. :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #7 on: December 14, 2008, 10:34:38 PM »
Thanks you sir, more to come. :)

I need to add a user pick to the remove reactor.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #8 on: December 14, 2008, 11:42:49 PM »
Updated the Routine. 12/14/2008 Version 1.3
Bug fix & cleaned up some of the code.
Also added some notes.
More work needed.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

cjw

  • Newt
  • Posts: 162
Re: Length Reactor
« Reply #9 on: December 15, 2008, 04:09:36 AM »
awesome!!!
CAB, You, good man!
I have set myself to learn from you!
pay my respects to you! :-)
The slow need to start early!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #10 on: December 15, 2008, 08:28:58 AM »
Thanks cjw,
I'm learning my self. :-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Length Reactor
« Reply #11 on: December 15, 2008, 04:55:04 PM »
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 '.

Quote
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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Length Reactor
« Reply #12 on: December 15, 2008, 05:24:56 PM »
I couldn't find how to release a transient reactor, but this change will not show the message anymore.

Code: [Select]
(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]
        )
    )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Length Reactor
« Reply #13 on: December 15, 2008, 09:52:41 PM »
Thanks Tim, I'll look into it tomorrow.
Been out most of the evening and I'm out of gas.  :-P
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.