See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Delete a Field When Replacing Our Titleblocks

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

    Default Delete a Field When Replacing Our Titleblocks

    Hello,

    First off, I'm still trying to learn lisp. Every time I get a moment to try something I get super busy again, so everything gets lost. Lol. I've tried searching for this, but I guess I'm just not finding something that will click in my brain to help me. I am trying to revise the lisp that was written many years ago by someone else.

    This is not the same question I had back in 2018. That part I was able to get working.

    Ok, scenario here. We have a retitle lisp that will replace our old titleblocks with new ones. We had several different types and sizes. We were able to condense the number of titleblocks we use. These drawings are mixed with some titleblocks on model tab and some on paper space. The old titleblocks had the drawing number in the title information area and a "dwg_no" block on the top left that had just the drawing number as well. That got the drawing number information when the titleblock was first inserted. Because the drawing number may change (by either a mere change or a saveas), the top left would have to be updated as well. This led to us updating the titleblock (current) using a field so anytime the drawing number changed, the upper left would update automatically. In the past, sometimes the upper left number would be forgotten to be updated. The lisp would determine the size and type of titleblock, remove the old titleblock, remove the dwg_no block that was on the top left, insert the new titleblock and replace the associated attributes.

    We had to make a change to the current titleblock making it the new one. The current titleblocks everything works great with running the retitle lisp to update the old titleblocks. The new replacing the old works well too. The issue is when replacing the current with the new is where I need some help. The titleblock gets removed and replaced as intended; however, the field remains. So, when the new gets inserted, there is a double field. I tried updating the new to not have the field to see if that would work, but it doesn't because that link is lost with the drawing number of the new titleblock.

    My question after that long explanation is, how can I get the field to be removed when I get the current titleblock removed? Not sure of the best way, but I was thinking it would be using the dxf codes. The field is on the same layer as the titleblock, "BORDER". I was thinking to erase everything on that layer, but thinking that if for some reason there is something else on that BORDER layer, that may be erased as well. I'm trying to think of how to pick that specific mtext. The scale can be different so I can't say to grab what's at the specific coordinate. Does this have a specific dxf code I can refer to or is there a better way that I'm not thinking of? Is it possible to get the existing field to link to the newly inserted titleblock? If so, then I could just have the new titleblock replaced without the field and allow the other lisp of inserting the new titleblocks for new drawings as normal with the field.

    *Edit to add the code*

    I tried to add the code using the code tags, but apparently it was too long and wouldn't allow me. So, I attached the code to the post. I also included a copy of the titleblock for reference.

    As I was playing with this, I found another issue that I was having and that is with the Size D. Our old titleblocks had a D size and that was not an Arch or ANSI size. So that is probably the reason that one size is not working right now. But I think I can just tweak that and be ok.

    I hope I gave a good explanation. Let me know if the mud needs to made a little clearer. Thanks in advance for the comments.

    Paul
    Attached Files Attached Files
    Last edited by pdstro; 2024-03-20 at 12:49 PM.

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

    Default Re: Delete a Field When Replacing Our Titleblocks

    Have you tried the ATTSYNC command to sync the attributes with the drawing?
    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
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Delete a Field When Replacing Our Titleblocks

    If you want help with your lisp, you need to post it (use code tags).

    I have a similar solution, written in C#. It assumes that there is only one paper space titleblock (located at 0,0) in a dwg. It stores the attributes of the current tb and inserts the user selected tb (from a network folder), purges the old tb and updates the new tb with the old attributes. This avoids having issues requiring ATTSYNC.
    C:> ED WORKING....


    LinkedIn

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

    Default Re: Delete a Field When Replacing Our Titleblocks

    Quote Originally Posted by Opie View Post
    Have you tried the ATTSYNC command to sync the attributes with the drawing?
    It did not work. I did the retitle then did the ATTSYNC after the new titleblock came in. The old field mtext did not link to the new draw_no attribute on the titleblock. The field that came in with the new titleblock works great as it should; however, there are two of them and the old one results in "##########". Unless I'm doing something wrong.

    Quote Originally Posted by Ed Jobe View Post
    If you want help with your lisp, you need to post it (use code tags).

    I have a similar solution, written in C#. It assumes that there is only one paper space titleblock (located at 0,0) in a dwg. It stores the attributes of the current tb and inserts the user selected tb (from a network folder), purges the old tb and updates the new tb with the old attributes. This avoids having issues requiring ATTSYNC.
    I did not include the lisp in case there was something that could be easily explained. Hoped anyway. I will edit the original post with it. The original lisp was made in the 90's to early 2000's so I'm sure things are better now and can be seriously revised and made better. I'm not that good yet. I am able to make some tweaks to help get it to work, just not overhaul it.

    Thanks, Paul

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

    Default Re: Delete a Field When Replacing Our Titleblocks

    Here is the code to delete fields in modelspace or paperspace layouts.

    P=

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard copyright 2024 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Functions for deleting fields
    ;___________________________________________________________________________________________________________|
    
    ;* C:FD
    ;* Command line hotkey function delete all fields in a drawing
    
    ;* C:FieldDelete
    ;* Command line function function delete all fields in a drawing
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Functions for deleting fields
    ;___________________________________________________________________________________________________________|
    
    ;  Function, Arguments and Description
    
    ;* (FieldDelete)
    ;* Function to delete fields in modelspace or paper space layouts
    
    ;* (SelectionSetToList1 ssSelections)
    ;* Function to convert a selection set of entities to a list of vla-objects
    
    ;$ End Header
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Command line function function delete all fields in a drawing
    ;___________________________________________________________________________________________________________|
    
    (defun C:FD ()
     (FieldDelete)
    )
    
    
    (defun C:FieldDelete ()
     (FieldDelete)
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to delete fields in modelspace or paper space layouts
    ;___________________________________________________________________________________________________________|
    
    (defun FieldDelete (/ lstObjects objSelection ssSelections strFieldCode)
     (if (and (setq ssSelections (ssget "x" (list (cons 0 "MTEXT"))))
              (setq lstObjects   (SelectionSetToList1 ssSelections))
         )
      (foreach objSelection lstObjects
       (if (and (setq strFieldCode  (vlax-invoke objSelection "FieldCode"))
                (wcmatch strFieldCode "*%<*>%*")
           )
        (vla-delete objSelection)
       )
      )
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to convert a selection set of entities to a list of vla-objects 
    ;___________________________________________________________________________________________________________|
    
    (defun SelectionSetToList1 (ssSelections / entSelection intCount lstObjects objSelection)
     (repeat (setq intCount (sslength ssSelections))
      (and (setq intCount     (1- intCount))
           (setq entSelection (ssname ssSelections intCount))
           (setq objSelection (vlax-ename->vla-object entSelection))
           (setq lstObjects   (cons objSelection lstObjects))
      )
     )
     lstObjects
    )
    
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

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

    Default Re: Delete a Field When Replacing Our Titleblocks

    Thanks Peter. Sorry for getting back late, but work happened. Lol. I tried it and it works great. Thank you. I was scared at first because it said it will delete all fields. We do have some blocks that have fields in them so I was hoping it wouldn't delete those as well. I guess it only deletes all the fields of the selected layer being deleted. I did some testing with various blocks and sizes and it works great. Had a little hiccup with one type of dwg, but I think I can get that working.

    I just wish I had better skills by this point. This needs rewritten to work better, but I'm not able to do that.

    Thanks again for the help. I'll reach out if I need help again.

    Paul

Similar Threads

  1. ###### Symbols Replacing Field Values
    By rbdome in forum AutoCAD Fields
    Replies: 1
    Last Post: 2017-06-05, 11:24 AM
  2. Delete and Delete All Page Setups
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2015-12-17, 06:38 AM
  3. Can't delete object with delete button
    By gtx in forum AutoCAD General
    Replies: 5
    Last Post: 2015-02-02, 01:52 AM
  4. Replies: 0
    Last Post: 2010-05-05, 02:38 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
  •