Author Topic: attribute detector...  (Read 3732 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
attribute detector...
« on: July 01, 2006, 12:18:44 AM »
Hi all...

I'm trying to detect if there is some attribute in a drawing..

 :|
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: attribute detector...
« Reply #1 on: July 01, 2006, 12:56:47 AM »
Why not use ssget?
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: attribute detector...
« Reply #2 on: July 01, 2006, 02:23:34 AM »
Have a play with this ..   but you really only need the first line, as CAB mentioned .. the rest is fluff.
Code: [Select]
(IF (SETQ ss (SSGET "X" '((0 . "INSERT") (66 . 1)))
     )
     (MAPCAR
         '(LAMBDA (ent)
              (LIST
                  (VLA-GET-NAME
                      (VLAX-ENAME->VLA-OBJECT ent)
                  )
                  (MAPCAR
                      '(LAMBDA (Att)
                           (CONS
                               (VLA-GET-TAGSTRING
                                   Att
                               )
                               (VLA-GET-TEXTSTRING
                                   Att
                               )
                           )
                       )
                      (VLAX-INVOKE
                          (VLAX-ENAME->VLA-OBJECT
                              ent
                          )
                          "GetAttributes"
                      )
                  )
              )
          )
         (REPEAT (SETQ len (SSLENGTH ss))
             (SETQ len (1- len)
                   l   (CONS (SSNAME ss len) l)
             )
         )
     )
 )

Edit:  Maverick will help you if you have any problems.
« Last Edit: July 01, 2006, 02:33:39 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: attribute detector...
« Reply #3 on: July 01, 2006, 02:25:32 AM »
.. returning something like this ..
Quote
(
 ("8700-31" (("LABEL" . "DETAIL") ("DET" . "S3d")
                                  ("DWG" . "W701")
                                  ("N1" . " ")
                                  ("N2" . " ")
                                  ("N3" . " ")
            )
 )
 ("W-03N" (("S" . "") ("R" . "") ("A" . "")))
 ("W-15T"
   (("N1" . "FLG'S") ("N2" . "& WEB") ("N3" . ""))
 )
 ("W-04N" (("S" . "") ("R" . "") ("A" . "")))
 ("W-04N" (("S" . "") ("R" . "") ("A" . "")))
 ("8700-31" (("LABEL" . "DETAIL") ("DET" . "S3c")
                                  ("DWG" . "W101")
                                  ("N1" . " ")
                                  ("N2" . " ")
                                  ("N3" . " ")
            )
 )
 ("8700-31" (("LABEL" . "DETAIL") ("DET" . "S3b")
                                  ("DWG" . "W101")
                                  ("N1" . " ")
                                  ("N2" . " ")
                                  ("N3" . " ")
            )
 )
 ("8700-31" (("LABEL" . "DETAIL") ("DET" . "S3a")
                                  ("DWG" . "W101")
                                  ("N1" . " ")
                                  ("N2" . " ")
                                  ("N3" . " ")
            )
 )
 ("W-04N" (("S" . "") ("R" . "") ("A" . "")))
 ("W-04N" (("S" . "") ("R" . "") ("A" . "")))
 ("BORDER-A1-DET-A016"
   (("DWG_NO_C" . "A016-S3")
     ("FOR_CON" . "FOR APPROVAL")
     ("REV_BOX" . "A")
     ("TITLE-1" . "ROM DUMP POCKET - DUMP HOPPER")
     ("TITLE-2" . "STRUCTURAL STEELWORK DETAILS")
     ("TITLE-3" . "SITE WELD DETAILS")
     ("DRAWN" . "RMK")
     ("DRAWN_DATE" . "MAY 06")
     ("REV_1" . "A")
     ("REV_1_T" . "ISSUED FOR APPROVAL")
     ("REV_1_D" . "DOC")
     ("REV_1_C" . "CTA")
     ("REV_1_A" . "CTA")
     ("REV_1_DA" . "JUN 13")
     ("DWG_MASS" . "")
   )
 )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: attribute detector...
« Reply #4 on: July 01, 2006, 11:15:21 PM »
Why not use ssget?


I was trying CAB....but not sure about how..

Thanks Kerry....
but guys......seriously....your to hot for me...
i'm lost when you r using VLAX VLR and other stuff like that..
i'm trying to lurn...but time missing..

So now....
this is my problem..

When using this code more than 3 times...

Code: [Select]
(setvar "attreq" 0)
(setq CBF (strcat "1" "=" "c:\\1.dwg"))
(vl-cmdf "_.-insert" CBF pause "1" "1" pause)
(if (ssget "X" '((0 . "INSERT") (66 . 1)))
(command "_.attsync" "_N" "1.dwg" ))
(command "_.explode" (entlast))
(setvar "attreq" 1)

i receive this ended message.
and AutoCAD close.

WHY !?

What i'm doing wrong ?

(note: the block is a simple block containing a simple attribute)
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: attribute detector...
« Reply #5 on: July 01, 2006, 11:33:18 PM »
Where is the closing parentheses for this IF statement?

Code: [Select]
(if (ssget "X" '((0 . "INSERT") (66 . 1))) ; <---<< 
My guess is it should be here
Code: [Select]
  (command "_.attsync" "_N" "1.dwg" ))
  (command "_.explode" (entlast))
) ; <---<<  Missing ?
(setvar "attreq" 1)


If it is somewhere else then you would need a (progn
Can't tell from you code fragment.
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: 4096
  • C3D user & customizer
Re: attribute detector...
« Reply #6 on: July 02, 2006, 01:19:07 AM »
ATTSYNC is an externally defined command (it is in Battman.arx) so it must be called differently else you get that error.....first, to make sure it's loaded:
Code: [Select]
(or (member "battman.arx" (arx))
    (arxload "battman")
    )
;;;now call it like so:
(acet-attsync "blockname")

Andrea

  • Water Moccasin
  • Posts: 2372
Re: attribute detector...
« Reply #7 on: July 02, 2006, 06:44:41 PM »
CAB...

(if (ssget "X" '((0 . "INSERT") (66 . 1)))
(command "_.attsync" "_N" "1.dwg" ))

the
Code: [Select]
  (command "_.explode" (entlast))and
Code: [Select]
  (setvar "attreq" 1)not need to be in the condition.

so what i'm doing wrong. ?
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: attribute detector...
« Reply #8 on: July 02, 2006, 06:56:55 PM »
Jeff.

Thanks...
but dont know why I need to load this arx to activate the acet function..

This is my real code....
(not working...)  :|
Code: [Select]
(if (and (eq CB_1 "1")(eq CB_4 "1"))
(progn
(setvar "attreq" 0)
(setq CBblockbase (vl-filename-base (strcat CBloc "\\" CB_iblock)))
(setq CBF (strcat CBblockbase "=" CBloc "\\" CB_iblock))
(vl-cmdf "_.-insert" CBF CBpick CBscale CBscale pause)
(if (ssget "X" '((0 . "INSERT") (66 . 1)))
(command "_.attsync" "_N" CB_iblock ))
(command "_explode" (entlast))
(setvar "attreq" 1)
))

And this is my new one...
(Jeff method, Working)  :-)
Code: [Select]
(if (and (eq CB_1 "1")(eq CB_4 "1"))
(progn
(setvar "attreq" 0)
(setq CBblockbase (vl-filename-base (strcat CBloc "\\" CB_iblock)))
(setq CBF (strcat CBblockbase "=" CBloc "\\" CB_iblock))
(vl-cmdf "_.-insert" CBF CBpick CBscale CBscale pause)
(or (member "battman.arx" (arx))
    (arxload "battman")
    )
(if (ssget "X" '((0 . "INSERT") (66 . 1)))
(acet-attsync (vl-filename-base CB_iblock)))
(command "_explode" (entlast))
(setvar "attreq" 1)
))

But don't know why..
Keep smile...

Serge J. Gianolla

  • Guest
Re: attribute detector...
« Reply #9 on: July 02, 2006, 07:25:49 PM »
Ciao ragazzo,

Have a look here http://www.4d-technologies.com/techcenter/index.htm
In the Blocks & Attribs. section, you might find something of interest for this or another project.

jurg's website has some subroutines for attributes too!

HTH

Andrea

  • Water Moccasin
  • Posts: 2372
Re: attribute detector...
« Reply #10 on: July 02, 2006, 08:18:05 PM »
Hey Sergio !!..

thanks for the link....
I've take a look..and many interesting think... :wink:

But the fact is...that I don't realy know why by changing my code to load the ACET function
is working....

what the difference between the (command "_.attsync" ....) and the (acet-attsync  .... )  ?
Keep smile...

Serge J. Gianolla

  • Guest
Re: attribute detector...
« Reply #11 on: July 02, 2006, 08:46:54 PM »
Hey Sergio !!..

thanks for the link....
I've take a look..and many interesting think... :wink:

But the fact is...that I don't realy know why by changing my code to load the ACET function
is working....

what the difference between the (command "_.attsync" ....) and the (acet-attsync  .... )  ?
Dunno! I am on 2006 and Battman is built-in.
May be the function is defined like (defun acet-attsync  ()... as opposed to (defun C:attsync  ()... get reshacker to have a look at the arx?
« Last Edit: July 02, 2006, 08:54:17 PM by Serge J. Gianolla »

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: attribute detector...
« Reply #12 on: July 03, 2006, 11:20:35 AM »
Dunno! I am on 2006 and Battman is built-in.
Serge, while Battman is no longer a member of ExpressTools, if you try Andrea's original code you will see that it still bombs with the "commands cannot be nested more than 4 deep" error. This is due to Adesk is still using the Battman.arx and (acet-attsync)...and still does in 2007 as well. I would have to think that this is for backward compatibility with older lisp programs.

Andrea, there is no real difference between the 2, except 1 will cause a Fatal Error and the other won't ;-) .......I believe that the command ATTSYNC calls the (acet-attsync) similarly to how I showed it.