PDA

View Full Version : copy a block reactor


rklee
2008-07-30, 05:27 PM
I am just starting to learn about reactors and the issues they can cause. I have been looking for a reactor the if the AutoCad copy command is used on an object (using vlr-object-reactor) then a flag is raised and the process is stopped. I have a special block creation routine, but I feel it is to lengthy for the call back function. Has anyone tried to create an object reactor that has a similar function? I do not want to just start trial and error since the effects on AutoCad are possibly damaging.

patrick35
2008-07-31, 07:42 AM
Hi

If this is for adding an object in Autocad (copy, array), look at the reactor of (vlr-acdb-reactor data callbacks) with event :vlr-objectAppended
If this is to intervene in the copy command, look reactor (vlr-command-reactor data callbacks) with event :vlr-commandWillStart or :vlr-commandEnded

@+

peter
2008-07-31, 01:22 PM
I am just starting to learn about reactors and the issues they can cause. I have been looking for a reactor the if the AutoCad copy command is used on an object (using vlr-object-reactor) then a flag is raised and the process is stopped. I have a special block creation routine, but I feel it is to lengthy for the call back function. Has anyone tried to create an object reactor that has a similar function? I do not want to just start trial and error since the effects on AutoCad are possibly damaging.

Well as for all reactors, you cannot stop a command once it starts. With a editor command ended reactor you can delete any new objects that were created on the last command. Use the commandtostart reactor to check to see if the command is the copy command. Then have it remember the (setq entLastEntity (entlast)). Then have the commandended reactor use the entnext expression

(while (setq entLastEntity (entnext entLastEntity))(entdel entLastEntity))

or some such function. The code above is not tested.

Hope that helps.

Peter

rklee
2008-08-01, 04:47 PM
Thanks for the input, I will be trying your suggestions. I am still thinking that I need an Object reactor since I am only concerned with certain blocks and not the rest of the drawing. The copy command is one that is used alot here and the slowdown of Autocad checking each time copy is used might cause me some issues.

peter
2008-08-02, 11:01 PM
Thanks for the input, I will be trying your suggestions. I am still thinking that I need an Object reactor since I am only concerned with certain blocks and not the rest of the drawing. The copy command is one that is used alot here and the slowdown of Autocad checking each time copy is used might cause me some issues.


I think you will find as I did when I played with the object reactors that maintaining them, adding them to objects handling the deletion of the objects, any of course undo means...

I found that a simple command ended reactor worked the best and was as fast as you are going to get with any reactor.

If when an operator creates a new block instance using the copy command or any command the routine I presented would detect it. Maybe you only want to delete certain blocks than have it convert the entity name into a object and check the effective name.

I coded a solution for you that may be more complicated than you need but I created a list of forbidden blocks:

;================================================================
;*****************************************************************************
(setq lstForbiddenBlocks (list "FRED" "GEORGE" "EDWARD" "peter"))
;*****************************************************************************
;================================================================

In the file change them to whatever name you want and load this function and then try to copy one or insert it... It will automatically delete it at the completion of the command. I just used common names for example.

Hope it helps.

Peter

rklee
2008-08-04, 07:34 PM
I have been looking over the program and when I tried to load it the message of "error: no function definition: LIbSTTOSAFEARRAY" comes up. I can figure out that you have a function that changes a list to a safe array. Looks interesting and I will be studying the methods of dealing with a reactor. The deleteing of the block will work nicely, just wondering, callbacks can not use the command functions or dialog boxes if I remember correctly. The users will have to read the command prompt to understand the correct method.

Thank you and have a good week.

peter
2008-08-04, 08:24 PM
Oops,

Here is that function.


; Convert list to Safearray
(defun ListToSafearray (symVariableType lstValues / safValues)
(setq safValues (vlax-make-safearray symVariableType (cons 0 (1- (length lstValues)))))
(vlax-safearray-fill safValues lstValues)
)

rklee
2008-08-07, 01:15 PM
Thank you, sorry I have been working on a software request involving the IT dept. and they like to make things difficult. Not sure when I will get to work on this, however I appreciate the help from everyone. This will give me something to look at how it works and hopefully I will start to understand reactors.

Thank you again.