Results 1 to 5 of 5

Thread: Renaming a Block After Testing

  1. #1
    Active Member
    Join Date
    2001-12
    Location
    Pittsburgh, PA
    Posts
    75
    Login to Give a bone
    0

    Default Renaming a Block After Testing

    Hello All,

    Wondering if I can get some help. Below is part of a bigger routine (I posted about before) that I am working on where I was replacing our title block with an updated version. That worked well, but I ran into a scenario that it doesn't work on, hence, adding this new part. The routine searches for the block named "title_block" and will pull the attributes and enter them into the new one. Based off the "size" attribute will determine which title block will be inserted. Once inserted, the block name will be renamed to "title_block".

    The scenario I ran into I have a title_block that was put into a drawing via a copy/paste I would guess. It still has the original block name, D Size. What I am looking for is a test to see if title_block exists and if not, rename it from one of the possible three sizes. There may be others, but these are the most probable ones. Once it gets renamed, then the rest of the routine should work as normal.

    Below is what I was able to get together. Not very good with lisp, but trying to get better. I'm sure what I have is wrong or could be done better. I have the "C:" in there because I was using this portion to test this out. Any thoughts?

    Code:
    (defun c:blkrnm (/ blknewnme)
    	(setq blknewnme 
    		(ssget "X" '((0 . "INSERT") (2. "TITLE_BLOCK"))))
      (if (null (tblsearch "block" "TITLE_BLOCK"))
    		(cond
    			((= blknewnme "C Size") (command "-rename" "b" "C Size" "TITLE_BLOCK"))
    			((= blknewnme "D Size") (command "-rename" "b" "D Size" "TITLE_BLOCK")) 
    			((= blknewnme "E Size") (command "-rename" "b" "E Size" "TITLE_BLOCK"))
    		)
    		(princ "Nothing Changed")
    	)
    )
    Thanks,

    Paul

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

    Default Re: Renaming a Block After Testing

    Your code doesn't make sense. The first line in the routine is attempting to create a selection set and save into a variable named blknewnme. You then check for a block definition not currently in the drawing. If that check is correct, you then cycle through the value of your previously saved selection set and attempt to evaluate that selection set to a string value. This evaluation is going to fail every time as a selection set cannot be converted directly to a string value.
    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

  3. #3
    Active Member
    Join Date
    2001-12
    Location
    Pittsburgh, PA
    Posts
    75
    Login to Give a bone
    0

    Default Re: Renaming a Block After Testing

    That's what I'm struggling with. In my mind things make sense, but how to apply that is what I need help with. My thinking was to look for the block title_block and if that is not there, look for the other block names and rename the one that is found. What is the proper way to do that?

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

    Default Re: Renaming a Block After Testing

    You would need to also search for each block definition you are attempting to rename. Of course, if you have renamed one to the title_block name, the other attempts would fail.

    In your code ...
    Code:
    (= blknewnme "C Size")
    replace with
    Code:
    (tblsearch "BLOCK" "C Size")
    Repeat similarly with the other block names you want to search and replace.

    Also, your first line doesn't really do anything other than create a selection set. The value assigned to that variable would not be used, therefore, it could potentially be removed.
    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

  5. #5
    Active Member
    Join Date
    2001-12
    Location
    Pittsburgh, PA
    Posts
    75
    Login to Give a bone
    0

    Default Re: Renaming a Block After Testing

    Thank you. That worked. I had the right idea in my mind of what I wanted to do, just a very bad thought and execution.

    Thanks again for your input.

Similar Threads

  1. Testing Testing 123
    By grantandersonvdc in forum New Forum Users (Non technical)
    Replies: 2
    Last Post: 2020-10-30, 05:37 PM
  2. Lost drawing after renaming
    By dls4706 in forum AutoCAD General
    Replies: 8
    Last Post: 2008-03-11, 02:03 PM
  3. Testing Testing Testing
    By d.gaither in forum New Forum Users (Non technical)
    Replies: 3
    Last Post: 2004-08-20, 05:03 PM
  4. testing....testing.....
    By Spectrefish in forum New Forum Users (Non technical)
    Replies: 0
    Last Post: 2004-08-18, 01:51 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
  •