Results 1 to 8 of 8

Thread: copy a block reactor

  1. #1
    Active Member
    Join Date
    2015-09
    Posts
    68
    Login to Give a bone
    0

    Red face copy a block reactor

    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.

  2. #2
    Member
    Join Date
    2008-07
    Posts
    19
    Login to Give a bone
    0

    Default Re: copy a block reactor

    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

    @+

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: copy a block reactor

    Quote Originally Posted by rklee View Post
    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

  4. #4
    Active Member
    Join Date
    2015-09
    Posts
    68
    Login to Give a bone
    0

    Default Re: copy a block reactor

    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.

  5. #5
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: copy a block reactor

    Quote Originally Posted by rklee View Post
    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
    Attached Files Attached Files
    Last edited by peter; 2008-08-04 at 07:26 PM.

  6. #6
    Active Member
    Join Date
    2015-09
    Posts
    68
    Login to Give a bone
    0

    Smile Re: copy a block reactor

    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.

  7. #7
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: copy a block reactor

    Oops,

    Here is that function.

    Code:
    
    ; 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)
    )
    

  8. #8
    Active Member
    Join Date
    2015-09
    Posts
    68
    Login to Give a bone
    0

    Smile Re: copy a block reactor

    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.

Similar Threads

  1. vlr-dwg-reactor issue MY FIRST REACTOR
    By treaves04413213 in forum AutoLISP
    Replies: 21
    Last Post: 2013-10-18, 12:36 PM
  2. Replies: 0
    Last Post: 2013-06-20, 08:03 AM
  3. Replies: 0
    Last Post: 2011-10-11, 08:38 AM
  4. Replies: 1
    Last Post: 2009-08-14, 01:05 PM
  5. Replies: 6
    Last Post: 2007-01-19, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •