Addnum Lisp routine no longer working - Any tips?

Addnum Lisp routine no longer working - Any tips?

jbowlesE4C6Z
Contributor Contributor
1,447 Views
7 Replies
Message 1 of 8

Addnum Lisp routine no longer working - Any tips?

jbowlesE4C6Z
Contributor
Contributor

I have a lisp routine I would use years back that is no longer working.  

Essentially the routine before would get rotation, starting number, and increment (number to add / subtract).  But the routine does not function as it did before.  What happened to the variables?

The big glitch is it no longer edits the attribute, it opens a diaglog box to enter instead of entering from command line script  My suspicion is that something changed with attribute definitions.  Any advice?   I feel like theres a system variable that needs to be set then reset.  
The ROUTINE is shown below:  

;Name : AddNUM.lsp
;Command : AddNUM
;created by jeremiah bowles
;******************************************************************
(defun c:Raddnum ()

;convert to degrees
; Convert value in radians to degrees
(defun Radian->Degrees (nbrOfRadians)
(* 180.0 (/ nbrOfRadians pi))
)
;setting rotation angle
; origional
; (setq rot (getangle "\nPick rotational angle:"))
; (setq rotd (* 180.0 (/ rot pi)))
;final script rotation if null
(setq rot (getangle "\nPick rotational angle:"))
(if (null rot) (setq rotd 0) (setq rotd (* 180.0 (/ rot pi)))
)
;setting the variables
(setq beg (getint "\nBegining of sequence of wall panel :"))
(setq pit (getint (strcat "\nIncrement :[ " "1" " ]")))
(if (= pit nil) (setq pit 1))
(setq k pit)

(while
(setq pt(getpoint "\nPick point :"))
(command "insert" "walltag" "r" rotd pt "1" "1" beg)
(prompt (strcat "<< " (rtos beg) " >>"))
(setq beg (+ beg k))
)

)

0 Likes
Accepted solutions (3)
1,448 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Check the setting of ATTREQ and ATTDIA sysvars.

Message 3 of 8

dlanorh
Advisor
Advisor
Accepted solution

Change

 

(command "insert" "walltag" "r" rotd pt "1" "1" beg)

 

to

 

(command "-insert" "walltag" "r" rotd pt "1" "1" beg)

 

I am not one of the robots you're looking for

0 Likes
Message 4 of 8

cadffm
Consultant
Consultant

@jbowlesE4C6Z 

 

see Z9E3zK5E answer, set ATTREQ=1 (it is now) and ATTDIA=0 (it is 1 now)

It's a good choice to add it into your code!

And if you can: create a *error* handler that restore these variable by canceling/crashs

 

lines above (while

(setq oldattdia (getvar 'attdia) oldattreq (getvar 'attreq))

(setvar 'attdia 0)

(setvar 'attreq 1)

 

and below the while part

(setvar 'attdia oldattdia)

(setvar 'attreq oldattreq)

 

 

{you don't need the change from INSERT to-INSERT, because of the (Command function will always start a version of -INSERT, also if you fire "INSERT" to the commandline}

Sebastian

0 Likes
Message 5 of 8

braudpat
Mentor
Mentor

Hello

 

If you are running NOW with ACAD version 2020/2021, maybe you have to use the command "CLASSICINSERT" and not "INSERT" !?

 

THE HEALTH, Regards, Patrice

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 6 of 8

cadffm
Consultant
Consultant
Accepted solution

No, for INSERT and CLASSICINSERT the commandlineversion is -INSERT,

Macro Script or (send)commands will start the -INSERT command from 2006

 

Sebastian

Message 7 of 8

cadffm
Consultant
Consultant
Accepted solution

@cadffm wrote:

No, for INSERT and CLASSICINSERT the commandlineversion is -INSERT,

Macro Script or (send)commands will start the -INSERT command from 2006,

EDIT:

or in v2021, the -INSERT command of 2021 (in 2021 '-INSERT' were added two more options: Explode and Repeat)

 


 

Sebastian

0 Likes
Message 8 of 8

ronjonp
Advisor
Advisor

When in doubt, remove those pesky command calls 😃.

;;Name : AddNUM.lsp
;;Command : AddNUM
;;created by jeremiah bowles
;;******************************************************************
(defun c:addnum	(/ _insertblock b beg pit pt rot rotd)
  ;; RJP » 2020-11-11 .. code cleaned up a bit
  (defun _insertblock (bname pt scl rot / b)
    (if	(and bname
	     (or (tblobjname "block" bname) (findfile (setq bname (strcat bname ".dwg"))))
	     (setq b (vla-insertblock
		       (vlax-get (vla-get-activedocument (vlax-get-acad-object))
				 (if (= (getvar 'cvport) 1)
				   'paperspace
				   'modelspace
				 )
		       )
		       (vlax-3d-point pt)
		       bname
		       scl
		       scl
		       scl
		       rot
		     )
	     )
	)
      b
    )
  )
  (if (and (or (setq rot (getangle "\nPick rotational angle:<0>")) (setq rot 0.))
	   (setq beg (getint "\nBeginning of sequence of wall panel :"))
	   (or (setq pit (getint (strcat "\nIncrement:<1>"))) (setq pit 1))
      )
    (while (setq pt (getpoint "\nPick pt :"))
      (if (setq b (_insertblock "walltag" pt 1. rot))
	(progn ;; (command "insert" "walltag" "r" rotd pt "1" "1" beg)
	       ;; Assumes that 'walltag' block only has one attribute
	       (vla-put-textstring (car (vlax-invoke b 'getattributes)) (itoa beg))
	       (prompt (strcat "<< " (rtos beg) " >>"))
	       (setq beg (+ beg pit))
	)
      )
    )
  )
  (princ)
)
(vl-load-com)
0 Likes