TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andrew_nao on May 03, 2013, 10:12:09 AM

Title: need a fresh set of eye please, code not working
Post by: andrew_nao on May 03, 2013, 10:12:09 AM
this code works in 2012, for some reason its not working in 2014

it inserts a tball with "1" and then for every time the lisp runs it inserts a new tball and automatically bumps the number up (2, 3, etc)
it keeps prompting me for input and it shouldnt

does anyone see anything wrong or know what is different in 2014 that would make this prompt me?


Code: [Select]
(defun c:tball ()
(setq ds (getvar "dimscale"))
(vl-load-com)
  (setq lm (vlax-ldata-get "leadnum" "currentnum"))
  (if (not lm)
    (setq lm (vlax-ldata-put "leadnum" "currentnum" 1))
   )
  (vl-cmdf "insert" "tball" pause ds ds "" (itoa lm))
  (vlax-ldata-put "leadnum" "currentnum" (1+ lm))
)
Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 03, 2013, 10:30:24 AM
the issue is this

vl-cmdf, anyone know why this doesnt work in 2014?

that whole line doesnt work. tball is a block with and attribute and it doesnt like it..

Title: Re: need a fresh set of eye please, code not working
Post by: Lee Mac on May 03, 2013, 10:38:44 AM
Try this untested code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tball ( / at bn cm lm )
  2.     (setq bn "tball") ;; Block Name
  3.    
  4.     (if (or (tblsearch "BLOCK" bn)
  5.             (setq bn (findfile (strcat bn ".dwg")))
  6.         )
  7.         (progn
  8.             (setq at (getvar 'attreq)
  9.                   cm (getvar 'cmdecho)
  10.             )
  11.             (setvar 'attreq 1)
  12.             (setvar 'cmdecho 0)
  13.             (if (null (setq lm (vlax-ldata-get "leadnum" "currentnum")))
  14.                 (setq lm (vlax-ldata-put "leadnum" "currentnum" 1))
  15.             )
  16.             (vl-cmdf "_.-insert" bn "_S" (getvar 'dimscale) "_R" 0.0 "\\" (itoa lm))
  17.             (vlax-ldata-put "leadnum" "currentnum" (1+ lm))
  18.             (setvar 'cmdecho cm)
  19.             (setvar 'attreq  at)
  20.         )
  21.         (princ "\nBlock not found.")
  22.     )
  23.     (princ)
  24. )            
Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 03, 2013, 10:48:04 AM
thanks for the reply Lee,
but this still prompts me for the value
Title: Re: need a fresh set of eye please, code not working
Post by: roy_043 on May 04, 2013, 02:31:11 AM
@andrew_nao:
Have you checked if the insert command has changed in AC2014? I suspect the attribute value may be used as the rotation angle when you use your code in AC2014.
Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 07, 2013, 01:19:04 PM
@andrew_nao:
Have you checked if the insert command has changed in AC2014? I suspect the attribute value may be used as the rotation angle when you use your code in AC2014.

the insert command still works the same way as far as i can tell when doing it manually

the "" would be the rotation angle... im still plugging away at this though, however with no success as to why this works in 2012 & 2013 and not 2014

Title: Re: need a fresh set of eye please, code not working
Post by: Lee Mac on May 07, 2013, 01:48:38 PM
What is printed to the command-line if you set CMDECHO to 1 in my code?
Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 08, 2013, 10:25:05 AM
What is printed to the command-line if you set CMDECHO to 1 in my code?

Command: TBALL
_.-insert Enter block name or [?] <A$C2DA246EE>: F:\acad\blocks\tball.dwg Substituting [SANSSB__.TTF] for [sasb____.pfb].


Units: Unitless   Conversion: 1.00000000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: _S Specify scale factor for XYZ axes <1>: 12.00000000000000 Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: _R
Specify rotation angle <0d0'0.00">: 0.000000000000000 Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Command: 1 Unknown command "1".  Press F1 for help.
Title: Re: need a fresh set of eye please, code not working
Post by: efernal on May 08, 2013, 10:37:01 AM
see attreq value...
Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 09, 2013, 09:45:33 AM
see attreq value...

thanks for the reply
that doesnt work for me either.

on 2012 its set to 1
when set to 0 the tball comes in with an X instead of a value.

this is mind boggling


Title: Re: need a fresh set of eye please, code not working
Post by: andrew_nao on May 10, 2013, 04:30:08 PM
what is the variable to turn off the dialog box prompt when inserting a block with attributes?

i think this is my issue but for the life of me cant remember that variable


edit: attdia needed to be set to 0 not 1

thanks for the replies everyone :)
Title: Re: need a fresh set of eye please, code not working
Post by: cmwade77 on May 10, 2013, 06:26:08 PM
Yes, they changed the default value of ATTDIA to 1, which broke most of my LISP routines, so I have added a setvar to my startup routines that always sets it back to 0 and it fixed all of this.
Title: Re: need a fresh set of eye please, code not working
Post by: TheMaster on May 11, 2013, 01:02:15 AM
Yes, they changed the default value of ATTDIA to 1, which broke most of my LISP routines, so I have added a setvar to my startup routines that always sets it back to 0 and it fixed all of this.

Changing the default value of ATTDIA isn't the sabotage.

The sabotage, was very deliberately not bothering to detect when input is coming from some form of scripting (LISP, menu macro, .SCR, etc), and always using the command line in that case.

Yes it is sabotage, because it is a simple matter to detect when the input comes from scripting, and in fact, many commands already do that and automatically use the command line.