Author Topic: Remove or modify all block descriptions  (Read 6452 times)

0 Members and 1 Guest are viewing this topic.

dustinthiesse

  • Guest
Re: Remove or modify all block descriptions
« Reply #15 on: January 06, 2009, 03:30:16 PM »
Makes perfect sense.  Thanks.
I was getting my info here http://www.jefferypsanders.com/autolispexp_enti.html#Block.
Great site, but the part there about the group code 70 is a bit misleading according to what you're telling me.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Remove or modify all block descriptions
« Reply #16 on: January 06, 2009, 03:47:04 PM »
You may want to play with this:
Code: [Select]
(defun c:test ()
  (while
    (cond
      ((null (setq data (entsel)))
       (princ "\nMissed, Try again.")
      )
      ((and (equal '(0 . "INSERT") (assoc 0 (setq elst (entget (car data)))))
            (not (zerop (logand 20 (cdr (assoc 70 (entget
                  (tblobjname "block" (cdr (assoc 2 elst))))))))))
       (princ "\nxRef not allowed, Try again.")
      )
      (t
       (prompt "\nValad selection.")
      )
    )
  )
  (princ)
)
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: 10401
Re: Remove or modify all block descriptions
« Reply #17 on: January 06, 2009, 03:49:46 PM »
Yes for the INSERT see this gropu 70
Code: [Select]
Insert group codes

Group code        Description
100      Subclass marker (AcDbBlockReference)
66       Variable attributes-follow flag (optional; default = 0); if the value of attributes-follow flag is 1, a series of attribute entities is expected to follow the insert, terminated by a seqend entity
2        Block name
10       Insertion point (in OCS)
DXF: X value; APP: 3D point
20, 30   DXF: Y and Z values of insertion point (in OCS)
41       X scale factor (optional; default = 1)
42       Y scale factor (optional; default = 1)
43       Z scale factor (optional; default = 1)
50       Rotation angle (optional; default = 0)
70       Column count (optional; default = 1)
71       Row count (optional; default = 1)
44       Column spacing (optional; default = 0)
45       Row spacing (optional; default = 0)
210      Extrusion direction (optional; default = 0, 0, 1)
DXF: X value; APP: 3D vector
220, 230 DXF: Y and Z values of extrusion direction (optional)
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.

dustinthiesse

  • Guest
Re: Remove or modify all block descriptions
« Reply #18 on: January 06, 2009, 04:19:16 PM »
Thanks CAB.  That code looked so simple at first, but it's really quite sophisticated.

One thing though, it allows for the selection of an entity that isn't a block.
I've split your 'and' statement into two separate conditions to check "insert" first, then check xref.

Code: [Select]
(defun c:test ()
  (while
    (cond
      ((null (setq data (entsel)))
       (princ "\nMissed, Try again.")
      )
      ((not (equal '(0 . "INSERT") (assoc 0 (setq elst (entget (car data))))))
       (princ "\nMust select a block, Try again.")
      )
      ((not (zerop (logand 20 (cdr (assoc 70 (entget
              (tblobjname "block" (cdr (assoc 2 elst)))))))))
       (princ "\nxRef not allowed, Try again.")
      )
      (t
       (prompt "\nValid selection.")
      )
    )
  )
  (princ)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Remove or modify all block descriptions
« Reply #19 on: January 06, 2009, 04:30:13 PM »
Thanks.
It was just a sample to play with.
Lots of possibilities.
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.

dustinthiesse

  • Guest
Re: Remove or modify all block descriptions
« Reply #20 on: January 06, 2009, 04:39:06 PM »
((and (equal '(0 . "INSERT") (assoc 0 (setq elst (entget (car data)))))
          (not (zerop (logand 20 (cdr (assoc 70 (entget
                  (tblobjname "block" (cdr (assoc 2 elst))))))))))
)

I spent a while trying to figure out why that 'and' statement didn't fail.
I finally realized that lisp must process each argument to the 'and' statement one by one and if it comes across one that is false then it immediately returns nil.  I just couldn't stop thinking 'how does that "(tblobjname..." not fail in the case where the selected object isn't a block!?
The 'equal' statement returns a false first and it never gets that far!!!
I get too excited about this stuff, I know.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Remove or modify all block descriptions
« Reply #21 on: January 06, 2009, 04:58:39 PM »
I get too excited about this stuff, I know.

You're in good company here.

Take a look at this post.
http://www.theswamp.org/index.php?topic=13046.msg158557#msg158557
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.