Author Topic: Problem retrieving Attribute Tags  (Read 5392 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 637
Re: Problem retrieving Attribute Tags
« Reply #15 on: May 29, 2012, 05:12:18 AM »
Maybe there's some sort of issue in 2006 with the vlax-for when it encounters a nested block reference.
yes. that's 2006 problem. i was able to make test on this version.
kruuger

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Problem retrieving Attribute Tags
« Reply #16 on: May 29, 2012, 09:08:32 AM »
It's not the Blockrefderence keeping the lisp from completing, it is the RTEXT object as I mentioned previously. Remove the RTEXT from the block and the routine will run all the way through. This is not a problem in newer versions (2010+?), as the RTEXT ActiveX code was fixed at some point.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Problem retrieving Attribute Tags
« Reply #17 on: May 29, 2012, 10:09:59 AM »
Exactly correct, I removed the Rtext from the block and it worked in 2006.
I added the Rtext back which cause it to be the last object in the block definition and it also worked.
Problem may come back it you edit the block (Battman or Block Editor) and any attribute edited may be placed after the Rtext.

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.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Problem retrieving Attribute Tags
« Reply #18 on: May 29, 2012, 12:14:03 PM »
So it's probably something like the ObjectName not defined as a property of RText, thus failing when that is called. Perhaps wrap it in a vl-catch-all-apply call. Or perhaps (if that still causes an error) wrap the vlax-for in a vl-catch-all-apply. Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:GetBlockInternals  (/ en eo blk lst)
  2.   (if (and (setq en (entsel "Select Block: "))
  3.            (setq eo (vlax-ename->vla-object (car en)))
  4.            (eq (vla-get-ObjectName eo) "AcDbBlockReference")
  5.                                (vla-get-EffectiveName eo))))
  6.     (vl-catch-all-apply
  7.       '(lambda ()
  8.          (vlax-for item  blk
  9.            (if (eq (vl-catch-all-apply 'vla-get-ObjectName (list item)) "AcDbAttributeDefinition")
  10.              (setq lst (cons (vla-get-PromptString item) lst)))))))
  11.   (reverse lst))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Problem retrieving Attribute Tags
« Reply #19 on: May 29, 2012, 12:36:10 PM »
CAB already tried the vl-catch-all-apply. Trouble is, it doesn't throw an error, it just stops the execution of the vlax-for loop. RTEXT just plain makes any ActiveX code (lisp and VBA) not work correctly. I complained to Autodesk about this quite often way back when I first encountered it. It took many years of complaining before it was corrected.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Problem retrieving Attribute Tags
« Reply #20 on: May 29, 2012, 01:20:47 PM »
So it's probably something like the ObjectName not defined as a property of RText, thus failing when that is called. Perhaps wrap it in a vl-catch-all-apply call. Or perhaps (if that still causes an error) wrap the vlax-for in a vl-catch-all-apply. Something like this:
This is what I get with the bad block:
Code: [Select]
Command: GETBLOCKINTERNALS
Select Block: nil
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.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Problem retrieving Attribute Tags
« Reply #21 on: May 29, 2012, 01:30:41 PM »
Hell! So the only workaround would be to use DXF codes instead. Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:GetAttributePrompts  (/ en eo blk lst)
  2.   (if (setq en (entsel "Select Block: "))
  3.     (if (> (atoi (getvar "ACADVER")) 16)
  4.       (if (and (setq eo (vlax-ename->vla-object (car en)))
  5.                (eq (vla-get-ObjectName eo) "AcDbBlockReference")
  6.                                    (vla-get-EffectiveName eo))))
  7.         (vlax-for item  blk
  8.           (if (eq (vla-get-ObjectName item) "AcDbAttributeDefinition")
  9.             (setq lst (cons (vla-get-PromptString item) lst)))))
  10.       (if (and (setq eo (entget (car en)))
  11.                (eq "INSERT" (cdr (assoc 0 eo)))
  12.                (setq en (tblobjname "BLOCK" (cdr (assoc 2 eo)))))
  13.         (while (setq en (entnext en))
  14.           (if (eq "ATTDEF" (cdr (assoc 0 (setq eo (entget en)))))
  15.             (setq lst (cons (cdr (assoc 3 eo)) lst)))))))
  16.   (reverse lst))
Hopefully the "fix" happened since 2007, otherwise the 16 needs to be altered.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.