Author Topic: Block filter specific to an attribute  (Read 5026 times)

0 Members and 1 Guest are viewing this topic.

Hugo

  • Bull Frog
  • Posts: 434
Block filter specific to an attribute
« on: May 11, 2011, 12:31:53 AM »
Hello

Is there a lisp that I can filter a block for an attribute.

1. Select an area
2. Block filter with the attribute ROOM / GROUP
3. Click on room number and include in the Atributte
the room number is in an x-ref.

Thanks

Block filtern nach einen bestimmten Attribut
Hallo

Gibt es ein Lisp, wo ich eine Blöcke filtern kann nach einem Attribut.

1. einen Raum wählen
2. Block filtern mit dem Attribut RAUM/GRUPPE
3. Raumnummer anklicken und in die Atributte übernehmen
die Raumnummer steht in einer x-ref.

Danke

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #1 on: May 11, 2011, 01:41:53 AM »
This code is from Lee, but unfortunately I will only Attributt last I want to change several Atributte.

Dieser Code ist von Lee, aber leider wird mir nur ein Attributt geändert ich will mehrere Atributte ändern.

Quote
(defun LM:SetAttributeValue ( block tag value / elist done )
  ;; © Lee Mac 2010
  (while
    (not
      (or
        (eq "SEQEND"
          (cdr
            (assoc 0
              (setq elist
                (entget
                  (setq block (entnext block))
                )
              )
            )
          )
        )
        done
      )
    )
    (if (eq tag (cdr (assoc 2 elist)))
      (progn
        (entupd
          (cdr
            (assoc -1
              (entmod
                (list (assoc -1 elist) (cons 1 value))
              )
            )
          )
        )
        (setq done value)
      )
    )
  )
)


(defun c:test ( / ss )

  (if (setq ss (ssget ":L" '((0 . "INSERT") (66 . 1))))
    ;(ssget "_+.:E:S:L"
    (LM:SetAttributeValue
      (ssname ss 0) (strcase  "L-2/18W")

      (getstring t "\nSpecify New Value: ")
    )
  )
 
  (princ)
  )

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #2 on: May 11, 2011, 02:02:50 AM »
i'm not sure. do you want something like this ?
kruuer

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #3 on: May 11, 2011, 02:55:12 AM »
Hello Kruuger

Yes it should be, but I will like to select multiple attributes, I must change this to an entire room




Ja so sollte es sein, aber ich will gleich mehrer Attribute auswählen können, ich muss das Attribut in einemganze Raum ändern.

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #4 on: May 11, 2011, 03:40:10 AM »
Where are the error
Wo ist ihr der Fehler

Quote
(defun LM:SetAttributeValue ( block tag value / elist done )
  ;; © Lee Mac 2010
  (while
    (not
      (or
        (eq "SEQEND"
          (cdr
            (assoc 0
              (setq elist
                (entget
                  (setq block (entnext block))
                )
              )
            )
          )
        )
        done
      )
    )
    (if (eq tag (cdr (assoc 2 elist)))
      (progn
        (entupd
          (cdr
            (assoc -1
              (entmod
                (list (assoc -1 elist) (cons 1 value))
              )
            )
          )
        )
        (setq done value)
      )
    )
  )
)


(defun c:test ( / ss )

  (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
  (while (setq e (ssname ss (setq i (1+ i))))
    (LM:SetAttributeValue
      (ssname e 0) (strcase  "RAUM/GRUPPE")
      (getstring t "\nSpecify New Value: ")
  )
  )
  )
  (princ)
  )

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #5 on: May 11, 2011, 04:01:00 AM »
you need step thru selection set. try this:
Code: [Select]
(defun c:TEST (/ SS)
  (if (setq SS (ssget "_X" '((0 . "INSERT") (66 . 1))))
    (if (setq ST (getstring T "\nSpecify New Value: "))
      (foreach % (kr:SSX_SS->VLA SS)
        (LM:SetAttributeValue % "RAUM/GRUPPE" ST)
      )
    )
  )
  (princ)
)
(defun kr:SSX_SS->VLA (Sel / N L#)
  (repeat (setq N (sslength Sel))
    (setq L# (cons (vlax-Ename->vla-Object (ssname Sel (setq N (1- N)))) L#))
  )
)
k.

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #6 on: May 11, 2011, 04:19:16 AM »
Error Message

Fehlermeldung


Specify New Value: 3/03.014
; Fehler: Fehlerhafter Argumenttyp: lentityp #<VLA-OBJECT IAcadBlockReference2
000000005869fc18>

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #7 on: May 11, 2011, 04:51:31 AM »
Error Message

Fehlermeldung


Specify New Value: 3/03.014
; Fehler: Fehlerhafter Argumenttyp: lentityp #<VLA-OBJECT IAcadBlockReference2
000000005869fc18>
hmm, could you post sample of your drawing ?
k.

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #8 on: May 11, 2011, 05:01:08 AM »
I will send you the drawing is very large  :cry:

soll ich ihnen die Zeichnung zusenden, ist aber sehr gross

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #9 on: May 11, 2011, 05:09:13 AM »
I will send you the drawing is very large  :cry:

soll ich ihnen die Zeichnung zusenden, ist aber sehr gross
try to save to new file with couple of blocks (which error of course)
kruuger

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #10 on: May 11, 2011, 05:21:10 AM »
Here is a small

Hier ein kleiner Ausscnitt

Specify New Value: 1
; Fehler: Fehlerhafter Argumenttyp: lentityp #<VLA-OBJECT IAcadBlockReference2
000000003eb34b68>

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #11 on: May 11, 2011, 05:38:28 AM »
Here is a small

Hier ein kleiner Ausscnitt

Specify New Value: 1
; Fehler: Fehlerhafter Argumenttyp: lentityp #<VLA-OBJECT IAcadBlockReference2
000000003eb34b68>
works fine for me. no error.
try to find error with this http://lee-mac.com/debugvlide.html
kruuger

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #12 on: May 11, 2011, 06:14:09 AM »
(defun LM:SetAttributeValue ( block tag value / elist done )
  ;; © Lee Mac 2010
  (while
    (not
      (or
        (eq "SEQEND"
          (cdr
            (assoc 0
              (setq elist
                (entget
                  (setq block (entnext block)) here is error hier ist fehler
                )
              )
            )
          )
        )
        done
      )
    )
    (if (eq tag (cdr (assoc 2 elist)))
      (progn
        (entupd
          (cdr
            (assoc -1
              (entmod
                (list (assoc -1 elist) (cons 1 value))
              )
            )
          )
        )
        (setq done value)
      )
    )
  )
)

kruuger

  • Swamp Rat
  • Posts: 637
Re: Block filter specific to an attribute
« Reply #13 on: May 11, 2011, 06:35:35 AM »
if you want to use my test function you need to load this (visual version):
Code: [Select]
(defun LM:SetAttributeValue ( block tag value )
  ;; Š Lee Mac 2010
  (vl-some
    (function
      (lambda ( attrib )
        (if (eq tag (vla-get-TagString attrib))
          (progn (vla-put-TextString attrib value) value)
        )
      )
    )
    (vlax-invoke block 'GetAttributes)
  )
)
if you wish vanilla my test needs to be like this (with Lee vanilla version):
Code: [Select]
(defun c:TEST (/ SS)
  (if (setq SS (ssget "_X" '((0 . "INSERT") (66 . 1))))
    (if (setq ST (getstring T "\nSpecify New Value: "))
      (foreach % (kr:SSX_SS->EnList SS)
        (LM:SetAttributeValue % "RAUM/GRUPPE" ST)
      )
    )
  )
  (princ)
)
(defun kr:SSX_SS->EnList (Sel / N L)
  (repeat (setq N (sslength Sel))
    (setq L (cons (ssname Sel (setq N (1- N))) L))
  )
)
kruuger

Hugo

  • Bull Frog
  • Posts: 434
Re: Block filter specific to an attribute
« Reply #14 on: May 11, 2011, 06:42:06 AM »
Super
Thank you it works.  :lol: :lol:

I must adjust so that I can choose a "FPolygon.

Thanks in advance



Super
Danke das funktioniert.  :lol: :lol:

was muss ich Einstellen damit  ich ein "FPolygon" wählen kann.



Danke im Vorraus
« Last Edit: May 11, 2011, 07:31:48 AM by Hugo »