Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Modify attributes in blocks with visibility states that have changed

  1. #1
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Modify attributes in blocks with visibility states that have changed

    I have a bunch of isometric blocks with attributes in them. I will occasionally need to change the value of one or more of the attributes by picking individual blocks. I found a program by Yancka that does part of what I need. The BIG problem is if the "visibility state" of the block has been changed then the attrbute value will not be changed. Even if the visibility state is changed back to the default insertion state the attribute values are not updated. I am attaching a DWG with three blocks in it to show what happens. I am also attaching the code from Yancka that I modified for my block and attribute names. It originally updated a revision attribute. Works great globally for blocks that have not had their visibility states changed. My programming skills are just not that good but I will keep trying and hope someone has the solution for this. Thank you, Jack.
    Attached Files Attached Files

  2. #2
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    I do have a crude solution for myself if this is too difficult to do. I figured that I can set ATTDISP to on and see all of the attributes. Then I can use this program I created many years ago. It allows you to pick a text string and then pick another text string and it is changed to the first text string you picked. This is a crude method but it beats double clicking and manually editing each attribute.

    (defun c:KCTS2S (/ E1 E2 L1 L2 L3 L4 ED2)
    (PRINC "\nPick FIRST text string to change SECOND text string to: ")
    (setq e1 (entsel));select entity
    (setq L1(entget (car e1 )));gets list of all its info
    (setq L2(cdr (assoc 1 L1)))
    (PRINC "\nPick TEXT string to receive FIRST text string value: ")
    (setq e2 (entsel));select entity
    (setq L3(entget (car e2 )));gets list of all its info
    ;(setq L4(cdr (assoc 1 L3)))
    (setq ed2 (subst (cons 1 L2)(assoc 1 L3)L3))(entmod ed2)
    (princ))

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    Matching text strings is not the same as dealing with block attributes; especially not with dynamic blocks with visibility states.

    Perhaps iterate through a selection set of blocks, and filter for block instances that have the appropriate EffectiveName Property, then drill down into the GetAttributes Property Object to access and manipulate the needed Attribute Object's TextString Property.

    Re: Visibility States... Be sure to test for AllowedValues Property
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    You are SOOOOO FAR over my head it is not even funny. I have been programming for over 20 years and I should be ashamed to say that I still have not learned the trick to drilling down into blocks to get the really deep data. I can dig down iwth and "nentsel" and then I am lost. I wish I could but I can't. I really do appreciate your taking the time to reply and give me some advice. Unless I can find some other code online I will just have to use my crude pick and replace old style lisp program. Best thing is this will not need to be done but a few times so it won't hurt if I can't get this done. Thanks again, Jack.

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    No worries; I've only been programming for +/-2 years here and there but some Vets that I greatly respect seem to feel that I'm making good progress.

    Here may be where my personal preference comes into play... I prefer to use Visual LISP Objects as opposed to AutoLISP's Table Records, etc. purely because I personally find the methodology, and available Object Properties, Methods, and Events to be more intuitive, and frankly easier for me to understand.

    Posting from my iPhone at the moment; perhaps I can post a small example this week as my schedule permits.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    I had changed 2 one line of code
    See if this working now:
    Just a Q: But why dont you use the local variables?
    Code:
    ;;;Program found on AutoCAD discussion groups done by Yancka
    (defun c:urev( / );;;atts inserts ss1)
      (vl-load-com)
      (cond
        ((or (null (setq ss1 (ssget "X" '((0 . "INSERT")(2 . "`*U*,BallValve_Flip_01")(66 . 1)))));<-- added to filter `*U* to get anonimous blocks
    	 (= 0 (sslength ss1))
    	 )
         (princ "\nNo insertions of BallValve_Flip_01 found.")
         )
        (T
         (setq
           Inserts (vl-remove-if '(lambda(x)(not (eq "BallValve_Flip_01"(vla-get-effectivename x))))
                     (mapcar (function vlax-ename->vla-object)
    		       (vl-remove-if
    			 (function listp)
    			 (mapcar (function cadr) (ssnamex ss1))
    		       )
    	       )
           )
           ;;Get a list of attributes and their tagstrings, thus
           ;; ((tagstring1 . attributereference1)(tagstring2 . attributereference2)...)
           atts    (mapcar
    		 (function
    		   (lambda (att)
    		     (cons (vla-get-tagstring att) att)
    		   )
    		 )
    		 ;;build a list of all the attributes in all the insertions we found
    		 (apply
    		   'append
    		   (mapcar (function (lambda (i) (vlax-invoke i 'GetAttributes)))
    			   Inserts
    		   )
    		 )
    	       )
           ;;remove the attributes without the tagstring we want
           atts    (vl-remove-if-not
    		 (function
    		   (lambda (att)
    		     (= (car att) "UPOD")
    		   )
    		 )
    		 atts
    	       )
         )
         (foreach att atts
           (vla-put-textstring (cdr att) "HUH?")
           )
         )
        )
      )
    ~'J'~

  7. #7
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    Thanks a bunch, fixo. The reason I take out the local variables is so I can see what the variable values are after the program runs. I use the eye glass icon to open up the box that allows you to put in whatever variables you want and they update as the program runs. Sometimes I run in animated mode and I can see the variables change as the program runs. I do appreciate your help and I should have gotten back and checked sooner. I did see where you added the filter for the anonymous block. I had forgotten all about how AutoCAD turns them into anonymous blocks. That made me just realize the other day when I was using the filter command to find a bunch of blocks that some showed and some did not. That has to be the reason. When I go to work I will see if I can use an anonymous block in the "filter" command dialog box. You double educated me today. Thanks again and take care, Jack.

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    You're welcome Jack,
    Cheers

    Oleg

  9. #9
    Member
    Join Date
    2011-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    Hi jack.foster
    I don't know what purpose of your lisp function. In my opinion, using table parameter with visibility parameter is a good way. It's keep your attribute information exactly which you want.
    My block is work well with me, but now I want to control visibility (Display Type parameter) according with Type attribute. I mean that when I edit Type attribute so visibility state change arcord with this. I think your LISP file can do that, but I don't know how to modify.
    Do your have any solution for my problem?
    Thanks
    Attached Files Attached Files

  10. #10
    100 Club
    Join Date
    2000-11
    Posts
    140
    Login to Give a bone
    0

    Default Re: Modify attributes in blocks with visibility states that have changed

    I am not sure what you are trying to do. I read your description several times. Maybe you can explain it a little differently. I looked at your drawing and there were parts of a valve scattered around with one attribute that looked like it was multiline. The drawing was not a dynamic block so I was a little bit lost. The program that I posted allows you to pick one text string or attribute and it extracts that value into a variable. Then when you pick another text string or attribute it modifies it to what the value of the first one picked was.

    You mention visibility states so I am attaching a real simple block I created for showing a spec break in P&ID drawings. There are 4 attributes in the drawing and two visibility states so only two attributes show at one time. One important thing I learned was each of the attributes must have a different tag name. Even though you may use them in different visibility states they must be different names or AutoCAD gets confused as to which one you are working with. Learned that the hard way. This spec break was intended to insert onto a line already drawn at the spec break. I originally had 3 lines that you could stretch and realign the spec break with a jogged location but co-workers didn't like that and wanted to draw a line manually. The usual whatever?

    I have another program for working with P&ID's that allow you to pick 1, 2 or 3 attributes to get there values. Then you pick the same number of attributes to put the values picked into these you want to modify. I don't know if that would help you or anyone but thought I would ask/mention such.
    Attached Files Attached Files

Page 1 of 2 12 LastLast

Similar Threads

  1. Count visibility states of blocks
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2016-06-07, 12:57 PM
  2. Visibility states in blocks
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2013-01-23, 04:04 AM
  3. Replies: 0
    Last Post: 2013-01-23, 04:01 AM
  4. Dynamic blocks, Visibility states, Attributes
    By megumby in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2007-08-03, 05:06 AM
  5. Attributes not reading Visibility states correctly
    By Dwane Lindsey in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2005-12-20, 04:42 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
  •