Author Topic: Question regarding Autocad Command Reactors  (Read 2212 times)

0 Members and 1 Guest are viewing this topic.

Rich S

  • Mosquito
  • Posts: 4
Question regarding Autocad Command Reactors
« on: April 22, 2019, 01:05:42 PM »
I'm trying to learn reactors.  I'm pretty knowledgeable in Lisp and this is my first step into the frigid waters of Reactors...

I have an object reactor that updates MText based on changes to a rectangle.  The rectangle represents the "coverage area" of steel decking on a building.  If the user changes the "coverage area", the MText that is grouped with the rectangle updates to show the # of sheets of deck and the length of the deck.  Area Width / Panel Width = # of pieces and Area Length = length of deck.

We furnish our deck cut to *length*, but not to width (we furnish xx pieces at, say, 24" wide and they cut the last piece to the required width at the jobsite).  So, I want to restrict the user to "panel width" increments in the "area width" direction.  Also, since I'm working with buildings, the direction of the deck length will often vary.

When initially laying out the coverage area, I do this with grid snap units/modes and by setting a user coordinate system oriented to the deck area being drawn.

I'd like to have a command reactor that is triggered by a Grip-Stretch so that my callback could essentially orient the UCS to the "coverage area" that is being modified so the coverage area would snap to panel-width increments.

I'm stumped on this issue (so far):
The command reactor passes 2 arguments to the callback, the reactor calling on the callback and the command name that is active.  I have not figured out yet how to determine *which* coverage-area rectangle is being stretched so that I could determine the orientation of it.

Once I can identify the object being modified, then I can (hopefully) figure out how to simulate changing the UCS (since I can't call commands from a callback) - I'm thinking using sysvars to establish a polar snap angle/distance...

Any ideas or suggestions??  Thanks in advance!!!

Rich S

  • Mosquito
  • Posts: 4
Re: Question regarding Autocad Command Reactors
« Reply #1 on: April 22, 2019, 02:18:49 PM »
By the way...sorry for the multiple posts.  Each time I tried to submit the question, I got a "database error" message...so I started over!  LOL... :knuppel2:

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Question regarding Autocad Command Reactors
« Reply #2 on: April 22, 2019, 05:04:07 PM »
why have you decide to use a command reactor?
why not a vlr-acdb-reactor or vlr-object-reactor?

Rich S

  • Mosquito
  • Posts: 4
Re: Question regarding Autocad Command Reactors
« Reply #3 on: April 22, 2019, 06:15:24 PM »
I am using the object-modified reactor for the updating of the text based on the new rectangle size.

However, the object reactor happens *after* the grip-stretch has been completed.  I want to set my snapbase, snapang to be oriented with the location/rotation angle of the pre-modified rectangle orientation *before* the user drags the grip to the new location.

The only reactor that I've found so far that fires before the object has been changed is the command-willstart reactor.  Is there a "before modified" object reactor?

Thanks for your response!!

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Question regarding Autocad Command Reactors
« Reply #4 on: April 22, 2019, 06:55:20 PM »
Code: [Select]
(vlr-command-reactor "StartCommand" (list (cons :vlr-commandWillStart 'StartCommand)))
(defun StartCommand (reactor_object obj)
  (if (= (car obj) "GRIP_STRETCH")
    (ssgetfirst)
  )
)

Rich S

  • Mosquito
  • Posts: 4
Re: Question regarding Autocad Command Reactors
« Reply #5 on: April 23, 2019, 08:59:58 AM »
I experimented with that a little last night.  I think the "ssgetfirst" is going to work for me - much appreciated!!

Thanks for the nudge in the right direction!!

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Question regarding Autocad Command Reactors
« Reply #6 on: April 23, 2019, 11:15:00 AM »
Thanks for the nudge in the right direction!!
never mind
and welcome to TheSwamp