Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Complex Block Swap?

  1. #1
    Member
    Join Date
    2012-02
    Posts
    2
    Login to Give a bone
    0

    Default Complex Block Swap?

    Hi guys,

    First post on here but I have been using the site for a long time, gaining great knowledge from all the posters on here.

    Im a CAD user but dont really have much experience in AutoLISP or programming, apart from being to modify work done by others and tailor it to my needs and then run it in CAD.

    Basically, I have been asked by work to try and speed a process up that we currently have. Heres the scenario below, if anyone could help that would be great. Im not really expecting someone to write the routine/script but really just want feedback to see if its in the realms of possibilty.

    We have several thousand drawings on file, which we need to replace the blocks in each file with new ones (news one have 8x attributes, where as the old ones have none).

    Im after a tool that will make swapping a block for another a simple/simpler task.

    A batch swap would of been the answer but the insertion points of the blocks are all different, along with angle of rotation.

    This is how envisage the tool working:

    When in the drawing (i understand this will have to be done for each drawing)

    Run the tool

    Click on the block to be replaced

    The routine looks up the name of the existing block and selects the block it needs to be replaced with (could this be done with an excel sheet?)

    The user is then asked to choose a revised insertion point for the existing block (all new blocks have an insertion point in the bottom left corner, so the user would pick the bottom left corner of the existing block), this ensures the position of the block is exactly the same as the one to be inserted

    The block is replaced with the new one in the same position

    Rinse and repeat!


    Now i know i have will have to consider rotation in there somewhere, as many of the blocks are at different angles but i would presume some how the angle of the existing block could be worked out and then applied when inserting the new one.

    In terms of the excel sheet, im thinking that somehow it could be made that if block A is clicked it knows that is to be replaced with block A rev 2; and if block B is clicked it knows that is to be replaced with block B Rev 2.

    If anymore info is needed or oyu want me to explain, please dont hesitate to ask.

    Thanks in advance,

    Mark

  2. #2
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    well there are a couple of options
    1. redefine the block, by doing so, it will change what it looks like but keep the same rotations and positions
    2. replace the block, if you are in the drawing, you can swap the blocks.

    you can write a script that will allow you to do this in several drawings.
    you can have a lisp program specified to attsync after the block redefine.

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    Im not really expecting someone to write the routine/script but really just want feedback to see if its in the realms of possibilty.
    This is good to know.

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    Im after a tool that will make swapping a block for another a simple/simpler task.
    That is why most of us started programming.
    Quote Originally Posted by m4rk.wr1ght105915 View Post
    A batch swap would of been the answer but the insertion points of the blocks are all different, along with angle of rotation.
    You will need to provide a matrix of some sort to specify the relationships between the original blocks and the replacement blocks.

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    When in the drawing (i understand this will have to be done for each drawing)
    Once you get the routine working with most of the bugs out of the way, you might be able to have it executed on multiple drawings.
    Quote Originally Posted by m4rk.wr1ght105915 View Post
    Run the tool

    Click on the block to be replaced

    The routine looks up the name of the existing block and selects the block it needs to be replaced with (could this be done with an excel sheet?)
    There are some examples of communicating with Excel in these forums. I would recommend making this a task specific routine that you provide it a name and it returns a list of information on the replacement name along with other pertinent information for the new block. (see the matrix information above)
    Quote Originally Posted by m4rk.wr1ght105915 View Post
    The user is then asked to choose a revised insertion point for the existing block (all new blocks have an insertion point in the bottom left corner, so the user would pick the bottom left corner of the existing block), this ensures the position of the block is exactly the same as the one to be inserted
    Instead of the matrix, you might be able to get the extents of the previous block. However, if the block is rotated, this task may become more difficult to find the similar points between old and new blocks.

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    The block is replaced with the new one in the same position

    Rinse and repeat!


    Now i know i have will have to consider rotation in there somewhere, as many of the blocks are at different angles but i would presume some how the angle of the existing block could be worked out and then applied when inserting the new one.
    As long as the rotation is provided in the original block, then you would be able to copy that information. If the items are rotated within the block but the block maintains a 0 rotation, this will become a larger task.
    Quote Originally Posted by m4rk.wr1ght105915 View Post
    In terms of the excel sheet, im thinking that somehow it could be made that if block A is clicked it knows that is to be replaced with block A rev 2; and if block B is clicked it knows that is to be replaced with block B Rev 2.

    If anymore info is needed or oyu want me to explain, please dont hesitate to ask.

    Thanks in advance,

    Mark
    I would recommend doing task specific routines to accomplish the overall function. Once each task specific routine is working, add calls to them in an overall routine to finish it up.

    You might try this routine to communicate with Excel. I have not used it in some time, so I am not positive it continues to work with the latest versions of Excel. It should though.

    If you have specific questions on these tasks, just ask.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    Member
    Join Date
    2012-02
    Posts
    2
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    ccowgill - sorry but ive already considered and discounted those commands, as i believe the routine is going to be far more complex. thanks for the response though

    opie - seems like you have got the jist of what i want to do, thanks for taking the time to repsond. however, i think alot of it will be way over my head. do you believe its something i get someone to help me with? either for free or for a fee?

    thanks again both for your help.

  5. #5
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    Hi guys,
    We have several thousand drawings on file, which we need to replace the blocks in each file with new ones (news one have 8x attributes, where as the old ones have none).

    Mark
    What will the basis/source for the values for attributes? or are those constant values? if you want a program to breeze thru a thouand drawings you may want a smart code for the assigning the values that doesnt requrie user input, with that approach the program should be able to distinguish what values to assign to which block.

    I would suggest *.txt or *.csv for data source rather than Excel format *.xls

    As explain to you by Opie, the rest is easy cheesy lemon squeezy.
    (he made it sound so easy really )

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Quote Originally Posted by m4rk.wr1ght105915 View Post
    ccowgill - sorry but ive already considered and discounted those commands, as i believe the routine is going to be far more complex. thanks for the response though

    opie - seems like you have got the jist of what i want to do, thanks for taking the time to repsond. however, i think alot of it will be way over my head. do you believe its something i get someone to help me with? either for free or for a fee?

    thanks again both for your help.
    Why would any of this be over your head? Don't you already know how to do all of these steps manually?

    How would you find out the name of the original block? You would use the list command or maybe the properties palette or maybe even another way that I cannot think of at the moment. To do that through code, you would need to ask the user to select the block. You could use the entsel function or even create a selection set with the ssget function.

    Using the entsel function, you would be able to select one object in the drawing. With this, you would be able to customize the prompt shown to the user. However, you would not be able to filter the types of objects one could select. You would need to take that into account.

    With entsel, the information provided would be a list. The first item in the list would be the ename and the second would be another list containing the coordinates from the pick point used to select the object. If no objects are in the pick box, the return value will be nil, meaning nothing was selected. You are not able to provide an option to the user to select anything using a window or crossing window type of selection.

    To get the data from the ename, you would need to use the entget function. You would need to use that function on the first item from the list provided by the previous entsel function.

    Once you get the entity data from the ename, you will need to look at the appropriate group code. I'll let you look that information up on your own.

    Now, can you create a routine that would return the block name of a chosen block? Remember, the last expression in a routine is the value returned from said function.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Don't know if you still need help or not. I have a program I wrote that has you pick a block in the current open drawing. Then you browse to find the block you want to replace it with. That is followed by three more buttons on the dialog box that you need to pick. The program writes a script file to work on all of the drawings in the current open drawings folder. Does an insert equals which redefines the block so they should all keep the same scale rotation whatever. The big question is what about all the new attributes and how you will fill them in. If you are interested let me know and I will see what I can do. I tried attaching the VLX file which would be easier for me but it wouldn't allow me to do such. Not trying to be stingy, just some of my stuff is pretty crude but works for rme. If in the US I have 3000 rollover minutes. Hopefull I can help. I have to make sure I am subscribed to this thread so I know when there is a reply.

  8. #8
    Active Member
    Join Date
    2006-05
    Location
    Columbus, Oh
    Posts
    52
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Please post that 3D Jack. I'm have a similar issue. Your Program may work perfect.
    Thanks!

  9. #9
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Quote Originally Posted by freedomonek View Post
    Please post that 3D Jack. I'm have a similar issue. Your Program may work perfect.
    Thanks!
    This was a long time ago. I will have to go back into my archives and find the program and make sure it works like it did for me. Then I will post it. I have put a reminder in my Outlook so I don't forget. I have a lot to do today but I will definitely find and post for you.

  10. #10
    Active Member
    Join Date
    2006-05
    Location
    Columbus, Oh
    Posts
    52
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Appreciate it 3D Jack. I tried the Express Tool "BlockReplace" routine, but it replaces all instances that were placed in the drawing.
    I have, in this case, many 3d Kitchen layouts in a single drawing, made-up of many identical Cabinet blocks (by-Size). I would like to pick on a certain size Cabinet block and swap it only with another block without it changing ALL instances.

    Thanks!
    Kelley

Page 1 of 3 123 LastLast

Similar Threads

  1. 2014: Complex Dynamic Block Issues
    By mbrandt5 in forum Dynamic Blocks - Technical
    Replies: 15
    Last Post: 2015-04-27, 10:55 PM
  2. 2014: Complex Dynamic Block problem
    By gambibolduc2563069 in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2014-02-25, 09:54 PM
  3. 2012: Complex Block Color
    By alien_srp in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2012-05-03, 05:47 PM
  4. Complex Block (I think)
    By mike.mccall in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-07-27, 07:11 PM
  5. Solids-block swap
    By bruce.jones542083 in forum AutoLISP
    Replies: 2
    Last Post: 2009-04-03, 02:18 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
  •