Jump to content

Do I need a lisp?


Herewegoagain

Recommended Posts

Hi I wonder can anybody help pleeeeeeeeease??

 

I need to add a new tag to an attribute in around 350 drawings. I can do this using Bedit and attsync within a drawing, but does anyone have any idea if a fix can be applied to all drawings??

 

Absolutely any help will be greatly appreciated!!

 

Thanks

Andy

Link to comment
Share on other sites

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    9

  • dbroada

    7

  • Herewegoagain

    7

  • ReMark

    3

Top Posters In This Topic

Hey thanks ReMark,

A script? as you can probably tell, i'm a bit of a novice, and understand nothing of Lisps or scripts.

Are you saying it is possible to do what I want to do?

Link to comment
Share on other sites

It is within the realm of possibility.

 

Think about the steps one would take to accomplish the task. That's the start of your script. The next part is applying the fix to 350 drawings. You do have a list of all the drawings right?

Link to comment
Share on other sites

Yeah I have a full list of all the drawings, all contained within various folders on a drive at work.

 

As I say I have no idea about scripts but I like a challenge and will now learn, I just didn't want to waste loads of time researching rying to achieve something that couldn't be done!

 

Thanks again, your help is really appreciated!!

Link to comment
Share on other sites

what exactly do you meanby add a tag to an attribute?

 

every attribute has one tag, one prompt and one text string. A block can be a collection of attributes and once inserted in to a drawing only the text strings will be visible.

Link to comment
Share on other sites

As an alternative to ScriptPro, I'm not sure if my ScriptWriter program will help (link in my sig). :)

ScriptPro does have the advantage of ignoring any strange popups (eg. Land Desktop project association warning) and will allow you to select files located in different locations.

Link to comment
Share on other sites

what exactly do you meanby add a tag to an attribute?

 

every attribute has one tag, one prompt and one text string. A block can be a collection of attributes and once inserted in to a drawing only the text strings will be visible.

 

Sorry, maybe it was my description, I guess I meant - I have a collection of attributes as a block which I would like to ammend to add another attribute to. I then need to apply this across 350 drawings.

 

I have a bit of reading to do I can see that, but when I think I know what im taliking about i'll take a look at both the ScriptPro, and your ScriptWriter Lee Mac.

 

Thanks again everyone for your help

 

Andy

Link to comment
Share on other sites

I'm not saying my program is anywhere near as good as ScriptPro, but if you want something quick, without the hassle of downloading/installing...
Oh, I know, I just wanted to state that information. Nothing at all against ScriptWriter.
Link to comment
Share on other sites

I think adding an attribute to an existing block is possibly beyond the ability of a script program (and Lee knows how much I like scripts).

 

However, are all your 350 blocks identical? If they are then its firmly back into script territory, if they are many different blocks that each need the same additional attribute added then its back to LISP (or VBA).

Link to comment
Share on other sites

I think adding an attribute to an existing block is possibly beyond the ability of a script program (and Lee knows how much I like scripts).

 

However, are all your 350 blocks identical? If they are then its firmly back into script territory, if they are many different blocks that each need the same additional attribute added then its back to LISP (or VBA).

 

Hell, if it's the same block, just partially insert the newly modified version of block to redefine old one and sync the old blocks.

Link to comment
Share on other sites

Hell, if it's the same block, just partially insert the newly modified version of block to redefine old one and sync the old blocks.
that is why I asked. If its the same block its simple. If its a different block in each drawing then its less easy in script.
Link to comment
Share on other sites

that is why I asked. If its the same block its simple. If its a different block in each drawing then its less easy in script.

 

I know. I was just adding on to what you had said.

Link to comment
Share on other sites

Hell, if it's the same block, just partially insert the newly modified version of block to redefine old one and sync the old blocks.

 

Yeah it's all the same block, the drawings are floor plans and it's the room data block/ attribute which contains room name, number, area etc and I want to add a floor attribute in. Does this mean there could be an easier fix? Like I say I can do it easily in each drawing individually by using bedit and attsync, but I was wondering if there might be some sort of global fix although I am out my depth and have no idea what I'm talking about!!

Link to comment
Share on other sites

Dave (and most probably Alan) will correct me, but I would think perhaps to create your block as you want it, insert this block into the drawing (it should have the same name as the old one) and then attsync to update for the new attrib.

 

Maybe something like this:

 

(defun c:ReDef ( / *error* GetActiveSpace spc nb un )
 (vl-load-com)
 ;; Lee Mac  ~  22.04.10

 (defun *error* (msg)
   (and un (vla-EndUndoMark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (defun GetActiveSpace (doc)
   (if (or (eq AcModelSpace (vla-get-ActiveSpace doc))
           (eq :vlax-true   (vla-get-MSpace doc)))
     (vla-get-ModelSpace doc)
     (vla-get-PaperSpace doc)))

 (setq spc (GetActiveSpace
             (setq doc (vla-get-ActiveDocument
                         (vlax-get-acad-object)))))

 (if (setq nb (getfiled "Select Block" "" "dwg" 16))
   (progn
     (setq un (not (vla-StartUndoMark doc)))

     (vla-delete (vla-insertblock spc
                   (vlax-3D-point '(0 0 0)) nb 1. 1. 1. 0.))

     (vl-cmdf "_.attsync" "_N" (vl-filename-base nb))

     (setq un (vla-EndUndoMark doc))))

 (princ))

If the above works, I could modify it for use in a script. :)

 

Lee

Link to comment
Share on other sites

Dave (and most probably Alan) will correct me, but I would think perhaps to create your block as you want it, insert this block into the drawing (it should have the same name as the old one) and then attsync to update for the new attrib.

 

Maybe something like this:

 

LoL

 

vla-insertblock won't Redefine the block if it already exists. It will just use the existing definition.

 

Try it with the following:

(vl-cmdf "_.-insert" (strcat nb "=") nil)

Forgot to explain:

The "=" will tell AutoCAD to redefine an existing definition (will still continue if doesn't exist) and if you send nil to the command after the block has been inserted, it will end the command without inserting an actual block. The definition will be in the drawing, but you won't have inserted an actual block.

29n84ep.jpg

Link to comment
Share on other sites

Dave (and most probably Alan) will correct me, but I would think perhaps to create your block as you want it, insert this block into the drawing (it should have the same name as the old one) and then attsync to update for the new attrib.

 

Maybe something like this:

 

(defun c:ReDef ( / *error* GetActiveSpace spc nb un )
 (vl-load-com)
 ;; Lee Mac  ~  22.04.10

 (defun *error* (msg)
   (and un (vla-EndUndoMark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (defun GetActiveSpace (doc)
   (if (or (eq AcModelSpace (vla-get-ActiveSpace doc))
           (eq :vlax-true   (vla-get-MSpace doc)))
     (vla-get-ModelSpace doc)
     (vla-get-PaperSpace doc)))

 (setq spc (GetActiveSpace
             (setq doc (vla-get-ActiveDocument
                         (vlax-get-acad-object)))))

 (if (setq nb (getfiled "Select Block" "" "dwg" 16))
   (progn
     (setq un (not (vla-StartUndoMark doc)))

     (vla-delete (vla-insertblock spc
                   (vlax-3D-point '(0 0 0)) nb 1. 1. 1. 0.))

     (vl-cmdf "_.attsync" "_N" (vl-filename-base nb))

     (setq un (vla-EndUndoMark doc))))

 (princ))

If the above works, I could modify it for use in a script. :)

 

Lee

 

Lee, above lisp works fine here.

1-call up original block with attributes in new drawing

2- use Bedit to add one or more additional attributes

3- close Bedit window

4-enter attsync

5- Wblock revised block to overwrite original block

6- call up dwg with blocks to be updated

7- load and run ReDef

8-clap hands together !!!!!!!

 

Steve

Link to comment
Share on other sites

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...