Jump to content

Need Reactor Advice/Guidance


sublimation

Recommended Posts

I am creating a program to generate mill slots and to update (using reactors) if a centerline is modified.  The only thing I can't figure out is how to handle the reactors for the secondary entities linked to the one being modified.

 

I am currently approaching the problem like so:

Each centerline has xdata that contains the handle of the outline followed by the handles of the other linked centerlines.

When the magenta line is modified, the outline will be deleted and a new outline will be generated based on the linked items, but that means a new handle needs to be added to the two other lines.  (I will have a similar and more complex problem when a new line crosses/interacts with the polylines)  I've tried modifying xdata once before and it ended up stuck in a loop.  I thought that by modifying the xdata my object modified reactor would trigger but it didn't seem to.

 

I don't have any working code ready to post yet, but what I really could use is some advice or guidance on the logic to trigger my reactors on secondary objects.  

 

image.thumb.png.443758d14739d60dcfb5b26c7055eca9.png

 

Thanks for looking!

 

Link to comment
Share on other sites

Obviously you'll need to use object reactor(s) - So there would be "master" and "slave" objects.

I would use a list datastructure like so: (list (list <master1> <master2> ... <masterN>) (list <slave1> <slave2> ... <slaveN>))

By manipulating any of the masters in the first set, the reactor would trigger changes to the second set for all the slaves.

Say this datastructure would represent only one set of those outlines and linked centerlines.

Then I could expand it by setting it as a part of a larger list, which would contain multiple sublists.

And I would store all this data as handles into some dictionary.

Then upon modifying any object within the reactor, check for the associated outline data in this list, perform changes on the entities and modify/store/rewrite the data.

Unfortunately no thoughts about erasing/copying and re/un-doing. Perhaps check this example.

 

  • Like 1
Link to comment
Share on other sites

I think parametric constraints will work better than using reactors... maybe you can give that a shot.

  • Like 1
Link to comment
Share on other sites

14 hours ago, Grrr said:

Obviously you'll need to use object reactor(s) - So there would be "master" and "slave" objects.

I would use a list datastructure like so: (list (list <master1> <master2> ... <masterN>) (list <slave1> <slave2> ... <slaveN>))

By manipulating any of the masters in the first set, the reactor would trigger changes to the second set for all the slaves.

Say this datastructure would represent only one set of those outlines and linked centerlines.

Then I could expand it by setting it as a part of a larger list, which would contain multiple sublists.

I've got my data structure set up like this:

(list -3
    (list ms:app
        (1000 . "S1")
        (1040 . 0.125)
        
        (1000 . "{")
        (1005 . labelhandle)
        (1005 . outlinehandle)
        (1000 . "}")
        
        (1000 . "{")
        (1005 . polylinehandle1)
        (1005 . polylinehandle2)

        (1000 . "}")
        )
    )

 

Are you saying the reactor would trigger automatically for the 2 polylinehandle entities?

 

The real challenge happens when I create another slot though.  Initially a new slot--the vertical one in EX 3 (I forgot to color it)--would be created, but the reactor would need to trigger and combine the new slot with the slot that it crosses (EX 4).  

 

image.png.48ec9fef07f235b452fb10a8eb09bd22.png

 

 

15 hours ago, Grrr said:

Unfortunately no thoughts about erasing/copying and re/un-doing. Perhaps check this example.

I have studied a bunch of LM's programs and I have created a couple of reactors that handle copying and erasing.

 

 

13 hours ago, Jonathan Handojo said:

I think parametric constraints will work better than using reactors... maybe you can give that a shot.

 

13 hours ago, BIGAL said:

Like jonathon dynamic blocks. have a look at this. Has shapes etc.

Parking Tools - Metric.dwg 425.86 kB · 0 downloads

That's really cool!  I will look into that for some other projects, but for this one I don't think they will work.

 

Link to comment
Share on other sites

No worries it is very smart.

 

Would it be easier to just have some create new, erase and recreate lisp.

 

Something like this with your shapes.

 

image.png.1482e32f443d3ba8fe3977e5c39488c0.png

  • Like 1
Link to comment
Share on other sites

Suppose this is your geometry:

image.png.acfdcf64c43afb24ec7e783c7b8ad8e6.png

 

When you're done, use the AUTOCONSTRAINT command (or optionally go here).

 

image.thumb.png.82f7f0b10ff89d3d38714b794d6b1740.png

 

Go to Settings first, check the Coincident, Parallel, Tangent and Concentric while leaving the rest unchecked:

image.png.53ce945fbffb0ddf3c6d99ad0f8233b3.png

 

Click OK and select the whole red and white curves and enter.

 

image.png.5a4ad64b3c1ccb1b76490bf488a1e1d5.png

 

Now you can move the white lines and the red ones will follow.

  • Like 1
Link to comment
Share on other sites

Due to anxiety issues I am actually pretty horrible at describing things and I apologize.

 

These are vacuum feed slots for extrusion dies and I draw 20 - 30 unique slots per die.  I am essentially trying to create a closed multi-polyline that updates when centerlines are moved or when a new line intersects with a previous line.  I can't seem to figure out how to trigger the reactor for polylines that are not currently part of the profiles xdata.  I really appreciate everyone's help, but I really think reactors are key to this.

 

Last night I did find the event reactor :VLR-modifiedXData.  Unfortunately, AutoDesk is as good at describing things as I am, as I can't find any documentation on it.  I figure it might work like :vlr-modified.  Not sure if it should create a command reactor (like one would do with :VLR-modified) or lisp reactor inside.  Does anyone have any experience with :VLR-modifiedXData?

Link to comment
Share on other sites

From my experience using reactors, I for one hate using vlr-modified. There's just way too many factors to take into account to ensure a code that's working properly. Given time and effort, sure it works:

 

1. Ensuring the outline is editable in an unlocked and thawed layer

 

2. Undoing and redoing (vlr-modified triggers on undo and redo) which may lead to your codes malfunctioning (because you can't modify objects whilst undoing or redoing).

 

3. If used wrong, may cause in an infinite vlr-modified loop between "master" and "slave" objects.

 

With every passing error that is invoked, I believe AutoCAD become more fragile. If used frequently, may even cause CAD to crash unexpectedly. It happens a lot for me and I've learned a painful lesson to never use it again unless I'm very experienced. I'd probably recommend just using parametric constraints because they're also basically reactors too like automatic dimensions.

 

I basically only use reactors for very simple purposes, like automatically saving the current file upon running some specific AutoCAD commands or LISP routines.

  • Like 1
Link to comment
Share on other sites

As I suggested earlier "Would it be easier to just have some create new, erase and recreate lisp".

 

If you constrain the object then some changes can occur re Jonathan, it may be just have options delete & add which remove constraints, do edit then redo the Autoconstraint. Going down the reactor direction may take more effort than a delete and add.

Link to comment
Share on other sites

15 hours ago, Jonathan Handojo said:

1. Ensuring the outline is editable in an unlocked and thawed layer

Done.

 

15 hours ago, Jonathan Handojo said:

2. Undoing and redoing (vlr-modified triggers on undo and redo) which may lead to your codes malfunctioning (because you can't modify objects whilst undoing or redoing).

Working on it.

 

15 hours ago, Jonathan Handojo said:

3. If used wrong, may cause in an infinite vlr-modified loop between "master" and "slave" objects.

Then it will cause a loop and I'll have to fix that.

 

11 hours ago, BIGAL said:

As I suggested earlier "Would it be easier to just have some create new, erase and recreate lisp".

Yes, probably. But, unfortunately, it's not how I want to go about it. By going the reactor route, I will end up with a more powerful program. 

 

 

I do truly appreciate all the help and suggestions that everyone has given me on this project. I am not looking for the easy way to solve this. I want to learn and grow as a programmer. Pushing the limits, even if I crash AutoCAD, is the only way to do that. I am interested in using reactors within my program because I think they will solve my problem in the best manner.  
 

  • Like 1
Link to comment
Share on other sites

On 8/5/2021 at 10:17 PM, sublimation said:

Done.

 

Working on it.

 

Then it will cause a loop and I'll have to fix that.

 

Yes, probably. But, unfortunately, it's not how I want to go about it. By going the reactor route, I will end up with a more powerful program. 

 

 

I do truly appreciate all the help and suggestions that everyone has given me on this project. I am not looking for the easy way to solve this. I want to learn and grow as a programmer. Pushing the limits, even if I crash AutoCAD, is the only way to do that. I am interested in using reactors within my program because I think they will solve my problem in the best manner.  
 

 

If you mind me asking, what sort of function do you use to generate your red outlines?

  • Like 1
Link to comment
Share on other sites

Thinking out of the square why not say 5 dynamic blocks much easier, 1up, 2up, 1up & 1down, 1up & 2down, 2up & 2down, use mirror where required, go back to my image choose which type. As shown can drag the white line to suit 90 or angle new start point and so on. 

Link to comment
Share on other sites

On 8/6/2021 at 8:41 PM, Jonathan Handojo said:

 

If you mind me asking, what sort of function do you use to generate your red outlines?

A double offset function that creates circles at the start and endpoints, then run those through a modified version of LM's OutlineObjects program. Then delete the construction geometry.

I can post it when I am done. I had to stop to play with :VLR-modifiedXData.

Link to comment
Share on other sites

1 hour ago, sublimation said:

A double offset function that creates circles at the start and endpoints, then run those through a modified version of LM's OutlineObjects program. Then delete the construction geometry.

I can post it when I am done. I had to stop to play with :VLR-modifiedXData.

 

I kinda thought so... You can't use reactors along with the "command" function because (getvar 'cmdactive) will always return 1 when a reactor is active. That is to say, when a reactor is active, you cannot invoke the "command" function because a previous command is still active. You'll have to use other methods, basically by using pure mathematics to calculate the points for the outline and the buldges and offsets required... It's going to be a huge headache for you my friend.

 

Oh, and let's note that the 3 points I mentioned above are just a few of the hundreds of points I had listed. Right here is another one, and there's heaps more.

Edited by Jonathan Handojo
  • Agree 1
Link to comment
Share on other sites

40 minutes ago, Jonathan Handojo said:

I kinda thought so... You can't use reactors along with the "command" function because (getvar 'cmdactive) will always return 1 when a reactor is active. That is to say, when a reactor is active, you cannot invoke the "command" function because a previous command is still active. You'll have to use other methods, basically pure mathematics to calculate the points for the outline.

 

Oh, that's right!  🤦‍♂️  Totally forgot that.

 

I guess I will be using maths then.  Start with a line, intersection points with other objects, add some bulges. Somewhere in between 'easy peasy lemon squeezy' and 'difficult difficult lemon difficult'.

Link to comment
Share on other sites

12 hours ago, BIGAL said:

Stay with multiple dynamic blocks as I suggested previously.

On 8/5/2021 at 8:17 AM, sublimation said:

I do truly appreciate all the help and suggestions that everyone has given me on this project. I am not looking for the easy way to solve this. I want to learn and grow as a programmer. Pushing the limits, even if I crash AutoCAD, is the only way to do that. I am interested in using reactors within my program because I think they will solve my problem in the best manner.  

 

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