Jump to content

Recommended Posts

Posted

Hi to everybody,

Is there a way to modify the tools blocks replace available in Autocad Express Tools ?.

 

I try to explain better :

- The express tools blocks replaces "all" blocks inside the dwg comparing the name.

- I would like to change only selected ones ? Is there a way to have access to express tools blocks replace "macro" and starting from that create another only for replace the selected one ?.

 

Somebody think that could be easier create complete new tools for my issue ?

 

Many thanks for all your support

Posted

Like match properties but matching blocks?

Posted
Like match properties but matching blocks?

 

I did not understood well your answer, but the original function matches the old blocks attributes with the new also.

My mod would be works in the same way.

 

Thanks

Posted

If I understand you correctly you have, for example, 12 instance of block "ABC" in your drawing. Of these 12 you may only want to change 6 of them not all of them. Is that right?

Posted

????

 

 
(defun c:mb (/ *error* ent ss ssent id)
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (setvar 'nomutt 0)
   (princ)
 )
 (while
   (not
     (and
(setq ent (car (entsel "\nSelect source block: ")))
(eq "INSERT" (cdr (assoc 0 (setq ent (entget ent)))))
     )
   )
   (prompt "\nPlease select a block!!")
 )
 (redraw (cdr (car ent)) 3)
 (prompt "\nSelect blocks to replace: ")
 (setvar 'nomutt 1)
 (repeat (setq id (sslength (setq ss (ssget '((0 . "insert"))))))
   (setq ssent (entget (ssname ss (setq id (1- id)))))
   (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent))
 )
 (setvar 'nomutt 0)
 (redraw (cdr (car ent)) 4)
 (princ)
)

Posted

Yes, correct.

Selecting that on screen, even if are in different layers.

 

Thanks

Posted
If I understand you correctly you have, for example, 12 instance of block "ABC" in your drawing. Of these 12 you may only want to change 6 of them not all of them. Is that right?

 

Yes, correct.

Selecting that on screen, even if are in different layers.

 

Thanks

Posted
????

 

 
(defun c:mb (/ *error* ent ss ssent id)
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (setvar 'nomutt 0)
   (princ)
 )
 (while
   (not
     (and
(setq ent (car (entsel "\nSelect source block: ")))
(eq "INSERT" (cdr (assoc 0 (setq ent (entget ent)))))
     )
   )
   (prompt "\nPlease select a block!!")
 )
 (redraw (cdr (car ent)) 3)
 (prompt "\nSelect blocks to replace: ")
 (setvar 'nomutt 1)
 (repeat (setq id (sslength (setq ss (ssget '((0 . "insert"))))))
   (setq ssent (entget (ssname ss (setq id (1- id)))))
   (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent))
 )
 (setvar 'nomutt 0)
 (redraw (cdr (car ent)) 4)
 (princ)
)

 

Seems to work fine, I'll try to select more than one

 

Many thanks

Posted
????

 

 
(defun c:mb (/ *error* ent ss ssent id)

   (entmod (subst (assoc 2 ([b][color="red"]entget[/color][/b] ent))(assoc 2 ssent) ssent))
 

 

You have forgotten to add entget function dear dan

 

Best regards

Posted

Seems that with your modification doesn't work !

Posted

WooHoo! I had logged in to ask about the very same issue. Lt. Dan's legs, you sir are awesome! With a couple of small tweaks this will do exactly what I need and save me several hours of fumbling around working out the code. Thank you for helping me to end my very bad week on a high note!

Mike

Posted

Watch out when replacing attributed blocks.

Posted
Watch out when replacing attributed blocks.

 

this correct Alan?

(defun c:mb (/ *error* ent ss ssent id)
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (setvar 'nomutt 0)
   (princ)
 )
 (while
   (not
     (and
(setq ent (car (entsel "\nSelect source block: ")))
(eq "INSERT" (cdr (assoc 0 (setq ent (entget ent)))))
     )
   )
   (prompt "\nPlease select a block!!")
 )
 (redraw (cdr (car ent)) 3)
 (prompt "\nSelect blocks to replace: ")
 (setvar 'nomutt 1)
 (repeat (setq id (sslength (setq ss (ssget '((0 . "insert"))))))
   (setq ssent (entget (ssname ss (setq id (1- id)))))
   (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent))
   [b][color=red](entupd ssent)
[/color][/b]  )
 (setvar 'nomutt 0)
 (redraw (cdr (car ent)) 4)
 (princ)
)

Posted

Entupd works on the entity, not it's data. Try entupd (cdr (assoc -1 ssent.

 

However, I'm talking about what will happen if you replace an attributed block. Try it, you will notice the attributes of the former block are still there. You will have to step through it (using entnext) and entdel each attribute.

 

I use the following; the replacement will only take on the rotation and size of the selected block and the original is just deleted.

http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block&p=359585&viewfull=1#post359585

 

BTW, nice work. You are really coming along with your coding.

Posted

Thank you to everybody for the support,

The last code seems to work fine only if the "destination" object to replace is a single object.

If I select more than one object just the last selected object will be replaced.

 

Pls Help Me.

Posted
Entupd works on the entity, not it's data. Try entupd (cdr (assoc -1 ssent.

 

However, I'm talking about what will happen if you replace an attributed block. Try it, you will notice the attributes of the former block are still there. You will have to step through it (using entnext) and entdel each attribute.

 

I use the following; the replacement will only take on the rotation and size of the selected block and the original is just deleted.

http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block&p=359585&viewfull=1#post359585

 

BTW, nice work. You are really coming along with your coding.

 

Thank you for your support but seems that your code do not transfer the attributes during the replacement, I need also to do this.

The best would be a mix between the two lsp, yours for multiple selection and the last from Lt Dan for the attributes.

 

Thank you !

  • 2 weeks later...
Posted
this correct Alan?

(defun c:mb (/ *error* ent ss ssent id)
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (setvar 'nomutt 0)
   (princ)
 )
 (while
   (not
     (and
(setq ent (car (entsel "\nSelect source block: ")))
(eq "INSERT" (cdr (assoc 0 (setq ent (entget ent)))))
     )
   )
   (prompt "\nPlease select a block!!")
 )
 (redraw (cdr (car ent)) 3)
 (prompt "\nSelect blocks to replace: ")
 (setvar 'nomutt 1)
 (repeat (setq id (sslength (setq ss (ssget '((0 . "insert"))))))
   (setq ssent (entget (ssname ss (setq id (1- id)))))
   (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent))
   [b][color=red](entupd ssent)
[/color][/b]  )
 (setvar 'nomutt 0)
 (redraw (cdr (car ent)) 4)
 (princ)
)

 

Thank you for your support, but seems that the above code substitutes only the block attribute and not the complete block with the source blocks attributes.

Thank You

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...