Author Topic: Attribute change  (Read 11413 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Bull Frog
  • Posts: 458
Re: Attribute change
« Reply #15 on: January 03, 2006, 05:56:41 PM »
Cab your awsome! Just what I was Looking for! Works perfect! Many thanks!

And many thanks to all who have tried to help!!!!!!!!!

The Swamp Rocks!!!!!!!!

deegeecees

  • Guest
Re: Attribute change
« Reply #16 on: January 03, 2006, 05:59:27 PM »
By the way, what is that Avatar yer using?

Its Lil' Ozzie, my first 3DStudio creation.

deegeecees

  • Guest
Re: Attribute change
« Reply #17 on: January 03, 2006, 06:02:30 PM »
Yes, CAB you truly do rock! I'm gonna have to give you a C- on your notation though...

<MP>Adusting score card</MP>

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Attribute change
« Reply #18 on: January 03, 2006, 06:06:11 PM »
Nice one CAB.  I was wondering how you would get the attribute if it was nested.  I see that you have to go through the blocks collection, and edit it there.  Nice to know.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 3948
  • C3D user & customizer
Re: Attribute change
« Reply #19 on: January 03, 2006, 06:28:45 PM »
Alan, I'd only advise 2 things.......(ssget "x") obtains the desired objects on ALL tabs, so when you step through the Blocks collection in place of the Model_Space check I would omit those that have the IsLayout = true. Otherwise you are stepping through those blocks twice.
Second, you could replace this:
(and (setq obj (vlax-ename->vla-object ent))
               (= (vla-get-objectname obj) "AcDbBlockReference")
               (= (vla-get-hasattributes obj) :vlax-true)
          )
with
(setq obj (vlax-ename->vla-object ent))

by filtering your SS like so:
(setq ss (ssget "_X" '((0 . "INSERT")(66 . 1)))

The 66 . 1 will filter for attributed blocks so no att check is needed.

just my 2 cents.....
« Last Edit: January 03, 2006, 06:33:05 PM by Jeff_M »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Attribute change
« Reply #20 on: January 03, 2006, 06:31:31 PM »
Editted : ^ ^ What he said ^ ^
Jeff types too quickly for me ..

Nice job Alan.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #21 on: January 03, 2006, 06:44:34 PM »
Yes, CAB you truly do rock! I'm gonna have to give you a C- on your notation though...

<MP>Adusting score card</MP>
What notation :-D
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #22 on: January 03, 2006, 07:00:11 PM »
OK, thanks for the info Jeff.
I'm starting to understand a little more on the block collections
Here is the revised code.

Code: [Select]
;;=======================[ cUpdate.lsp ]=======================
;;; Author: Copyright© 2006 Charles Alan Butler
;;; Version:  1.1 Jan. 03, 2006
;;; Purpose: To update attributes in a drawing, nested blocks & xref
;;;          Ignores locked or Frozen layers
;;; Sub_Routines: -None
;;; Requirements: -None
;;; Returns: -None
;;;==============================================================
;;
(defun c:cupdate (/ ss ent obj att blks newtext taglist)
  (setq newtext "2006 C-n-R CORPORATION"
        taglist '("COPYRIGHT" "COPYRIGHTYEAR"))
  (or *doc* (setq *doc* (vla-get-activedocument (vlax-get-acad-object))))
  (if (< 0 (vla-get-count (setq blks (vla-get-blocks *doc*))))
    (progn
      (vlax-for blk blks
        (vlax-for ent blk
          (if (and (vlax-property-available-p ent 'hasattributes)
                   (= (vla-get-hasattributes ent) :vlax-true)
              )
            (progn
              (foreach att (vlax-invoke ent 'getattributes)
                (if (member (vla-get-tagstring att) taglist)
                  (vla-put-textstring att newtext)
                )
              )
            )
          )
        )
      )
      (vla-regen *doc* acactiveviewport)
    )
  )
  (princ)
)
(prompt "\nCopyright Update Loaded, Enter cupdate to run.")
(princ)
« Last Edit: January 03, 2006, 07:09:33 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE

  • Guest
Re: Attribute change
« Reply #23 on: January 03, 2006, 07:12:56 PM »
Are almost ALL the blocks in the collection in need to be updated?
Why not making a normal selection set with SSGET and the filter, and then just use the active selection set ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #24 on: January 03, 2006, 07:16:40 PM »
Well the attribute in question could be in a block
or in a block within a block
or in a block within an xref

So i had a problem with the block within an xref. That is getting to it with ssget.
ssget finds the xref but not the nested block with the attribute.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE

  • Guest
Re: Attribute change
« Reply #25 on: January 03, 2006, 07:23:07 PM »
Well the attribute in question could be in a block
or in a block within a block
or in a block within an xref

So i had a problem with the block within an xref. That is getting to it with ssget.
ssget finds the xref but not the nested block with the attribute.

I see it now , sorry...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #26 on: January 03, 2006, 07:38:29 PM »
No problem Luis.

Thanks all, I can't take all the credit.
I borrowed code from Jeff's c:txt2std routine
and some from Kerry's routines. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 3948
  • C3D user & customizer
Re: Attribute change
« Reply #27 on: January 03, 2006, 07:51:49 PM »
Well the attribute in question could be in a block
or in a block within a block
or in a block within an xref

So i had a problem with the block within an xref. That is getting to it with ssget.
ssget finds the xref but not the nested block with the attribute.
I'm having a hard time understanding this part......If it's in an Xref you can't permanently change that  unless you edit the Xref drawing..... and even if you could, I would still use the (ssget) to get the Model/Paper space inserts w/attributes, then loop through the blocks collection examining only those non-Layout blocks. If you want to change the Xref, ObjectDBX will need to be added.......

Or am I missing something obvious..... ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #28 on: January 03, 2006, 08:09:55 PM »
I doubt you are missing anything. I didn't check the xref to see if the change was in that drawing.
I could not get the ssget to pick up the nested block. The test I did rejected the block as not having attributes.
I'll have to get back to this tomorrow when I can dig a little deeper to understand the non-layout issue.
Thanks Jeff
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: Attribute change
« Reply #29 on: January 03, 2006, 10:03:07 PM »
OK, Jeff.
If I do it this way with (if (= (vla-get-islayout blk) :vlax-false)
the plain blocks with attributes are overlooked as they are within the
model space block.
The nested block with attributes within a block and the xref are updated.
So without the exclusion the routine looks into each model & PS block to get
each insert with attributes.
What is the concern doing it this way? Too slow in a large drawing?

Code: [Select]
(defun c:cupdate (/ ss ent obj att blks newtext taglist)
  (setq newtext "2006 C-n-R CORPORATION"
        taglist '("COPYRIGHT" "COPYRIGHTYEAR"))
  (or *doc* (setq *doc* (vla-get-activedocument (vlax-get-acad-object))))
  (if (< 0 (vla-get-count (setq blks (vla-get-blocks *doc*))))
    (progn
      (vlax-for blk blks
         (if (= (vla-get-islayout blk) :vlax-false) ; exclude model & PS blockobjects   <-----<<<<< Oops , had this in the wrong spot
       (vlax-for ent blk
           (if (and (vlax-property-available-p ent 'hasattributes)
                   (= (vla-get-hasattributes ent) :vlax-true)
              )
            (progn
              (foreach att (vlax-invoke ent 'getattributes)
                (if (member (vla-get-tagstring att) taglist)
                  (vla-put-textstring att newtext)
                )
              )
            )
          )
         )
        )
      )
      (vla-regen *doc* acactiveviewport)
    )
  )
  (princ)
)
(prompt "\nCopyright Update Loaded, Enter cupdate to run.")
(princ)

Edit: move the if statement.
« Last Edit: January 03, 2006, 10:46:19 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.