VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Blocks Replace

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1053 Views, 7 Replies

Blocks Replace

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
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Hi,

 

For such a simple task, it would be far easier to start from scratch than try and break into the Express Tools code and modify it.

 

Message 3 of 8
joesull
in reply to: Anonymous

This might work for you. First change the UCS to World. Use the Wblock command to select the instances of the block you want to replace and write these to the newblock drawing (choose the option to erase the items from the drawing). Open the newblock drawing and run the Express tool to replace the blocks. Use the rename command to rename the blocks. Save and close the newblock drawing. Insert the newblock drawing back into your original drawing.

Message 4 of 8
Anonymous
in reply to: joesull

Thank you for your suggestion, but for me seems complicate, I'm working on a lisp routine which select a source blocks and the others to replace.

if you want you can find the code below

 

(defun c:mb1 (/ *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))
    (entupd ssent)
  )
  (setvar 'nomutt 0)
  (redraw (cdr (car ent)) 4)
  (princ)
)

 

 

Message 5 of 8
sardeson
in reply to: Anonymous

Since the code you are asking us to review is LISP and obtained verbatim from a posting by a member of CADTUtor.net; I suggest that you ...

 

1) Join the discussion at CADTutor and seek clarification to your problems using THEIR code on this post --> CADTUtor.net 

2) If you need help understanding LISP please ask your LISP questions in the Autodesk Forum for LISP programming ...  this is the VB forum

 

Message 6 of 8
Anonymous
in reply to: sardeson

Thank you for your reply, But I'm not asking to nobody to modify the lsp code, even if it's coming from another forum. I said that I'm working on that code, and I'm still working on it that was only a starting point, even if it's coming from another forum. I would like to add my personal idea on this your disappoint on the specific post. I think that the suggestion of two different forum are useful for everybody. I'm not using such code for profit, or a professional use. Thank you again for you suggestion
Message 7 of 8
Anonymous
in reply to: Anonymous

Her is your code

 

Regards

Message 8 of 8
Anonymous
in reply to: Anonymous

Thank you very much for your code, I'll try to modify more in order to avoid the block name inserting, perhaps selecting source and destination blocks on screen.

 

Thank you again

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost