Author Topic: command copy and reactor  (Read 1714 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
command copy and reactor
« on: March 04, 2012, 09:15:38 AM »
Hello everyone,
I finally finished my functions with the reactors!  :-)

I just need to refine some things, so I need your help.
1. you can make sure that when I copy an object with the command "COPY" will be copied
even the reactors?

2. I noticed that if I open the drawing without loading the function, when I modify an object with the reactors appears the following error message:

function definition: NAMEFUNCTION

You can avoid this annoying message without removing the persistent reactors?

Thanks in advance

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: command copy and reactor
« Reply #1 on: March 05, 2012, 01:50:48 AM »
For question 1: It "should" copy the object reactor together with the object when you perform a copy command. All that happens when you place an object reactor is that some dictionary data is attached to that object - acad then checks to see what defun to call when something happens to that object.

For 2: See the description above. The reactor and its callback is not saved onto the object (or even anywhere inside the DWG). All that is "persistent" is the link from the object to the defun. So if your defun (at least the call-back defun) is not already loaded - you will always have that error. And unfortunately you can't embed LSP into a DWG like you could with VBA.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lupo76

  • Bull Frog
  • Posts: 343
Re: command copy and reactor
« Reply #2 on: March 06, 2012, 06:50:10 AM »
For question 1: It "should" copy the object reactor together with the object when you perform a copy command. All that happens when you place an object reactor is that some dictionary data is attached to that object - acad then checks to see what defun to call when something happens to that object.

For 2: See the description above. The reactor and its callback is not saved onto the object (or even anywhere inside the DWG). All that is "persistent" is the link from the object to the defun. So if your defun (at least the call-back defun) is not already loaded - you will always have that error. And unfortunately you can't embed LSP into a DWG like you could with VBA.

Hello
thanks for the answer

For question 1: What should I do in practice? I have to redefine the command "copy" of AutoCAD so that you can also copy the reactor?

For question 2: ok for the reply, I am aware of the fact that the function is not built into dwg files, but I have seen applications developed by other developers (and therefore do not have the source code ...) that produce dwg files with objects where there is definitely a reactor: these files do not emit errors when you open them without loading functions. Maybe I'm missing something?  :ugly:

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: command copy and reactor
« Reply #3 on: March 06, 2012, 09:49:46 AM »
In practice you should not have to do anything other than perform a normal copy. E.g. if the object has a reactor attached to it, that same data will be copied to the new object. Thus the new object will also fire the reactor if you subsequently change it.

I'm not sure of anything embeddable in a DWG concerning reactors. The only embeddable stuff would be VBA code, and then you usually get confronted by an "Enable Macro" dialog whenever you open the DWG. I've seen some attempt at embedding LSP as XData / XRecords, then using an embedded VBA to load that LSP whenever the DWG is opened.

The problem with this approach is the client needs the VBA interpreter installed, which is not standard with the newer ACads.

Personally I'd create an installer for the LSP - have it load for each DWG through the acaddoc.lsp file (or whatever you prefer). That way you can send your installer to each PC which will work on these. ... Actually on second thought, I'd then also try to avoid persistent reactors.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lupo76

  • Bull Frog
  • Posts: 343
Re: command copy and reactor
« Reply #4 on: March 06, 2012, 09:59:04 AM »
1. The normal copy copying xdata correctly but does not copy the reactor!

2. never mind the VBA: I know all the negative aspects.
As I said, the "dwg" is to be distributed even to users who do not have installed my application and therefore should not generate errors when an object is changed!

I'm sure other applications do so in vlisp!

Precise that I am aware that if the lisp are not loaded, no action will be initiated when an object is edited, this is fine by me, but it must be issued no error
« Last Edit: March 06, 2012, 10:13:13 AM by Lupo76 »