Jump to content
Karan Patel

This command is prompting again and again.

Recommended Posts

Posted (edited)

i use this lisp file or this program to plot instruments in instrumentation layouts but from morning it is showing this message again and again aas bad argument type or file nil.

For this i have sent the link to the error of acad.

And i am attaching the lisp file.

 

please help me anyone, because i need to submit this drawing at earliest.

 

thanking all in advance to give me suggestion

 

 

 

 

 

 

;INSTRUMENT PLOTPLAN AUTOMATION PROGRAM
;HVB/DKJ
;global variables (sc fp x y px py dir line1 s2 sn TName TNumber w0 n0 el jb sym cnt north Xdir)

(DEFUN LIC_CHK()
(setq vba_file "c:/uilplotplan/acad.dvb")			;DVB consists of the License code. 
(if (/= (findfile vba_file) nil)
	(progn
		(print "Plot Plan application successfully loaded")
		(command "-VBARUN" "ThisDrawing.chk_expiry")  ; Load the license file code and check
		(command "delay" 3000) ; delay in ms
		(setq chkExp (open "c:/uilplotplan/chk_st.txt" "r"))     ; Chk_St.txt file used for returning value to Lisp and then decide if lisp  code has to resume
		(if  (= nil chkExp )	
			( print " File not found ")
		);
		(setq v1  (read-line chkExp))	
		(close chkExp)
		(print v1)
		
		(if  (= v1  "N") 
				(progn
						(command "save" "")
						;(alert "Cannot continue Plot Plan as license in not valid  ....Quitting the program!!") 
						(command "quit")
				);progn
		); if
	)
	(progn
		(alert "Error loading Plot Plan  application -  application file not found !\n\n\t Please contact administrator.\n\n\t\tQuitting application.")
		(command "quit")
	)
)
)


;---------------------------------------------
;main function for automating Inst plotplan
;|any comment for debugging|;
(defun icplot ()
(LIC_CHK)  
(command "sdi" 1)  ; allows only one active drawing 
(command "ATTDIA" 0)  ;;; Added by SNg 30-11-2004: E.g. for displaying Tag Details within the circle.
(command "layer" "m" "inlead-5" "c" "3" "inlead-5" "" ) ; Makes the INLEAD -5 layer for Lead line
(command "layer" "m" "insym-1" "c" "4" "insym-1" "" ) ; Makes the layer for inserting the symbol
(command "layer" "lock" "*" ""  )  ; locks all the layers 

 (initget (+ 1 2 4))  ;;Validation 
 (setq cscale (getreal "\nEnter the scale for the drawing  "))
  (initplot)
  (readfile)
  (setq sc nil fp nil x nil y nil px nil py nil Xdir nil)
  (setq line1 nil s2 nil sn nil TName nil TNumber nil north nil)
  (setq w0 nil n0 nil el nil jb nil sym nil cnt nil p4 nil)
)
;---------------------------------------------
;gets the initialization data (filename, scale, BenchMark)
(defun initplot(/ txtfile p1)

;;; following modified by Simran on 30-nov-04 : Changed the default path
  (initget +1 )
   (setq txtfile (getfiled  "Select TextFile for Plotting" "c:/uilplotplan" "txt" )
   
   (if ( = nil txtfile)
	(progn
	(alert " Input file is not selected ...Now quitting")
        (exit)
	);progn
   );if


  (setq sc cscale)
  (setq p1 (getpoint "\nClick on the BenchMark"))
  (initget (+ 1 2 4))  ;; Validation 
  (setq x  (getreal "\nEnter x-Coordinate (E/W on Piping Plan) of the BenchMark:"))
  (setq y  (getreal "\nEnter y-Coordinate (N/S on Piping Plan) of the BenchMark:"))
 

	(setq chk nil)	
	 (while (/= chk "T" )
	(setq north (getstring "\nEnter NORTH orientation in degrees e.g:0,90,180,270  "))
	:; validation for north direction
		( if  
			(or
			   ( = north "0")
			   ( = north "90")
			   ( = north "180")
			   ( = north "270")
			 );or
			(setq chk "T")
		(progn
			( setq chk "F")
			(princ)
		);progn 
		);if
	(princ)
	);while	


(initget  +1 "E W")
(setq Xdir (getkword "\nEnter PDMS convention(E for East / W for West) (W/E) :"))	
(setq Xdir ( strcase Xdir))	

	(setq ynk "N")  ; The automation has not been completed , hence hardcoded.In Future this code can be modified

(if (null fp) (princ) (close fp))

 (setq fp (open txtfile "r"))	
(setq px (car p1))
(setq py (cadr p1))
) ;DEFUN
;---------------------------------------------
;reads and processes the text file
(defun readfile()
  (setq line1 (read-line fp))
  (while (/= line1 nil)
    (str2list)
    (v_assign)
    (pltag)
    (setq line1 (read-line fp))
 );while
 (close fp)
( alert  " Plot Plan Completed successfully ")
)                                     
;---------------------------------------------
;converts string (line1) to list (s2)
(defun str2list(/ len counter s1 c1)
  (setq len (strlen line1))
  (setq counter 1 s1 "" s2 (list ""))
  (while (< counter (+ len 1))  
	    (setq c1 (substr line1 counter 1)) 
	    (if (= c1 ",")
		      (progn
			        (setq s2 (append s2 (list s1)) s1 "")	 
	      ) ;progn 
	      (setq s1 (strcat s1 c1)) 
	    ) ;if
	    (setq counter (+ counter 1))
  ) ;while
  (setq s2 (cdr (append s2 (list s1))))
)
;---------------------------------------------
;assigns values to (sn,TName,TNumber,X,Y,EL,JB,Sym,Cnt)
(defun v_assign(/ w0 n0 w n)
(setq sn      (nth 0 s2))   ;sr. number used when part of leader line is common
(if (= sn "") (setq sn " "))
  (setq w0      (nth 1 s2))(setq w0 (atof w0))
  (setq n0      (nth 2 s2))(setq n0 (atof n0))
  (setq sym     (nth 3 s2))
 	  (setq TNumber (nth 0 s2))
 ;transformation of coordinates
 (if (= north "90")
   (if (= Xdir "E")
     (progn
       (setq w (+ px  (- w0 x)))  ;north=90 pdms gives ENU
       (setq n (+ py  (- n0 y)))
     )
     (progn
       (setq w (+ px  (- x w0)))  ;north=90 pdms gives WNU
       (setq n (+ py  (- n0 y)))
     )
   ))

 (if (= north "0")
   (if (= Xdir "E")
     (progn
       (setq w (+ px  (- n0 y)))  ;north=0  pdms gives ENU
       (setq n (+ py  (- x w0)))
     )
     (progn
       (setq w (+ px  (- n0 y)))  ;north=0  pdms gives WNU
       (setq n (+ py  (- w0 x)))
     )
   ))

 (if (= north "180")
   (if (= Xdir "E")
     (progn
       (setq w (+ px  (- y n0)))  ;north=180  pdms gives ENU  check?
       (setq n (+ py  (- w0 x)))
     )
     (progn
       (setq w (+ px  (- y n0)))  ;north=180  pdms gives WNU
       (setq n (+ py  (- x w0)))
     )
   ))

 (if (= north "270")
   (if (= Xdir "E")
     (progn
       (setq w (+ px  (- x w0)))  ;north=270 pdms gives ENU  check?
       (setq n (+ py  (- y n0)))
     )
     (progn
       (setq w (+ px  (- w0 x)))  ;north=270 pdms gives WNU  check?
       (setq n (+ py  (- y n0)))
     )
   ))

 (setq pt (list w n))    ;insertion point for instrument 
)
;---------------------------------------------
;plots and labels the tags
(Defun pltag(/ p2 p3)
     (progn
     (command "ortho" "off")
     (setq p2 (list (car pt)  (+ (cadr pt) (* sc 20 )) 0))
     (command "insert" "Dot" pt sc sc 0)
     (setq p2 (getpoint pt "\nSelect first point of leader line:"))
     (command "layer" "set" "INLEAD-5" "")
     (command "line" pt p2 "")
     (command "ortho" "on")
     (if (= ynk  "Y")
(setq p3 p2)   
       (setq p3 (getpoint p2 "\nSelect next point:"))
     )
     (setq p4 p3)
     (if (= ynk  "N")
      (command "pline" pt  "w" 0 0  p2 p3 "")
     )
     (command "layer" "set" "INSYM-1" "")
     (if (> (car p2) (car p3))
       (progn
         (setq sym (strcat sym "_Left")) 
         (command "insert" sym p3 sc sc 0  TNumber))
       (progn
         (setq sym (strcat sym "_Right")) 
         (command "insert" sym p3 sc sc 0 TNumber))
     )
    )
)

;---------------------------------------------
(icplot)  ; Load the icplot function automatically
(princ)

 

file:///C:/Users/Karan%20Patel/Desktop/acad%20error.PNG

Edited by SLW210
Code Tags

Share this post


Link to post
Share on other sites
Posted (edited)

Welcome on Cad-Tutor , Karan Patel.

 

 

When you paste code first type "

" , after that paste your code , and close with "[/code ]" ... else you get smashed by that ugly green troll ;-)

 

 

For your code , nobody will have "c:/uilplotplan/acad.dvb" or "c:/uilplotplan/chk_st.txt" so nobody will be able to test it.

 

 

Only thing I can say in your function '(defun initplot...' , the line beginning with '(setq txtfile ... is missing a closing bracket ')'

 

 

Maybe this wil solve your problem. Else go to the visual lisp editor , make sure in pull down 'Debug' you enable 'Break on Error' and maybe also enable 'Animation so you can follow what is happening. If your code stops with an error your can select 'Error Trace' in the 'View' pull down and see where and why your code has stopped.

 

 

Good luck!

 

 

gr. Rlx

Edited by rlx

Share this post


Link to post
Share on other sites
Welcome on Cad-Tutor , Karan Patel.

 

 

When you paste code first type "

" , after that paste your code , and close with "[/code ]" ... else you get smashed by that ugly green troll ;-)

 

 

For your code , nobody will have "c:/uilplotplan/acad.dvb" or "c:/uilplotplan/chk_st.txt" so nobody will be able to test it.

 

 

Only thing I can say in your function '(defun initplot...' , the line beginning with '(setq txtfile ... is missing a closing bracket ')'

 

 

Maybe this wil solve your problem. Else go to the visual lisp editor , make sure in pull down 'Debug' you enable 'Break on Error' and maybe also enable 'Animation so you can follow what is happening. If your code stops with an error your can select 'Error Trace' in the 'View' pull down and see where and why your code has stopped.

 

 

Good luck!

 

 

gr. Rlx

 

 

Thnk u for ur suggestion frnd, but it don't work still.

 

Same error are prompting still.

 

please help, i'm in trouble

Share this post


Link to post
Share on other sites

You can probably disable license check by changing (lic_chk) to ;(lic-chk) in function icplot.

In function initplot the getfiled function is not complete , this probably should be :

 (setq txtfile (getfiled "Select TextFile for Plotting" "c:/uilplotplan" "txt" [b][color=red]0[/color][/b])) 

maybe you mean c:/uTilplotplan instead of uilplotplan? And this file , you read from it or you write to it? If its meant to read as your code suggest , how can anybody test your code without a drawing and without this txt file?

Share this post


Link to post
Share on other sites
You can probably disable license check by changing (lic_chk) to ;(lic-chk) in function icplot.

In function initplot the getfiled function is not complete , this probably should be :

 (setq txtfile (getfiled "Select TextFile for Plotting" "c:/uilplotplan" "txt" [b][color=red]0[/color][/b])) 

maybe you mean c:/uTilplotplan instead of uilplotplan? And this file , you read from it or you write to it? If its meant to read as your code suggest , how can anybody test your code without a drawing and without this txt file?

 

Means u need text fie and cad file to load this app,

please brother help me out with this.....

I have attached a zip file with one cad file, txt file, and one error occurred during loading that lisp photo.

And in the cad file red circle center will be benchmark for that drawing.

Scale for the drawing will be 200.

E co-ordinates will be 1278970

N co-ordinates will be 707770

We have to use co-ordinates in millimeter.

 

Please brother help me out with this.

Thanking you in advance.

Desktop.zip

Share this post


Link to post
Share on other sites

couldn't test everything because I don't have block 'Dot' but give it a try...

 

 

;INSTRUMENT PLOTPLAN AUTOMATION PROGRAM HVB/DKJ
;global variables (sc fp x y px py dir line1 s2 sn TName TNumber w0 n0 el jb sym cnt north Xdir)
;---------------------------------------------
;main function for automating Inst plotplan
(defun icplot  ()
 (command "sdi" 1)   ; allows only one active drawing 
 (command "ATTDIA" 0)
 ; Added by SNg 30-11-2004: E.g. for displaying Tag Details within the circle.
 ; Makes the INLEAD -5 layer for Lead line
 (command "layer" "m" "inlead-5" "c" "3" "inlead-5" "")
 ; Makes the layer for inserting the symbol
 (command "layer" "m" "insym-1" "c" "4" "insym-1" "")
 ; locks all the layers 
 (command "layer" "lock" "*" "") 
 (initget (+ 1 2 4))
 ;;Validation 
 (setq cscale (getreal "\nEnter the scale for the drawing "))
 (initplot)
 (readfile)
 (setq sc nil fp nil x nil y nil px nil py nil Xdir nil)
 (setq line1 nil s2 nil sn nil TName nil TNumber nil north nil)
 (setq w0  nil n0  nil el  nil jb  nil sym nil cnt nil p4  nil)
)
;---------------------------------------------
;gets the initialization data (filename, scale, BenchMark)
(defun initplot  (/ txtfile p1)
 ; following modified by Simran on 30-nov-04 : Changed the default path
 ; **** in the getfile path , change "" to your default folder , left it black to force selection
 (if (not (setq txtfile (getfiled "Select TextFile for Plotting" "" "txt" 0)))
   (progn (alert "Unable to load datafile - exit")(exit)))
 (setq sc cscale)
 (setq p1 (getpoint "\nClick on the BenchMark"))
 (initget (+ 1 2 4))
 ;; Validation 
 (setq x (getreal "\nEnter x-Coordinate (E/W on Piping Plan) of the BenchMark:"))
 (setq y (getreal "\nEnter y-Coordinate (N/S on Piping Plan) of the BenchMark:"))
 (setq chk nil)
 (while (/= chk "T")
   (setq north (getstring "\nEnter NORTH orientation in degrees e.g:0,90,180,270 "))
   (if (or (= north "0")(= north "90")(= north "180")(= north "270"))
     (setq chk "T") (progn (setq chk "F")(princ)))
   (princ)
 ) 
 (initget +1 "E W")
 (setq Xdir (getkword "\nEnter PDMS convention(E for East / W for West) (W/E) :"))
 (setq Xdir (strcase Xdir))
 (setq ynk "N") ; The automation has not been completed , hence hardcoded.In Future this code can be modified
 (if (null fp) (princ) (close fp))
 (setq fp (open txtfile "r"))
 (setq px (car p1))
 (setq py (cadr p1))
)    
;reads and processes the text file
(defun readfile  ()
 (if fp
   (progn
     (setq line1 (read-line fp))
     (while (/= line1 nil) (str2list) (v_assign) (pltag) (setq line1 (read-line fp)))
     (close fp)
     (alert " Plot Plan Completed successfully ")
   )
   (princ "\nUnable to read from file - null file pointer")
 )
)
;---------------------------------------------
;converts string (line1) to list (s2)
(defun str2list  (/ len counter s1 c1)
 (setq len (strlen line1) counter 1 s1 "" s2 (list ""))
 (while (< counter (+ len 1))
   (setq c1 (substr line1 counter 1))
   (if (= c1 ",") (setq s2 (append s2 (list s1)) s1 "") (setq s1 (strcat s1 c1)))
   (setq counter (+ counter 1))
 )
 (setq s2 (cdr (append s2 (list s1))))
)
;---------------------------------------------
;assigns values to (sn,TName,TNumber,X,Y,EL,JB,Sym,Cnt)
(defun v_assign  (/ w0 n0 w n)
 ;sr. number used when part of leader line is common   
 (if (= (setq sn (nth 0 s2)) "")(setq sn " "))
 (setq w0 (nth 1 s2) w0 (atof w0) n0 (nth 2 s2) n0 (atof n0) sym (nth 3 s2) TNumber (nth 0 s2))
 ; transformation of coordinates
 (cond
   ((= north "90")
    ;north=90 pdms gives ENU , north=90 pdms gives WNU
    (if (= Xdir "E")
      (setq w (+ px (- w0 x)) n (+ py (- n0 y))) (setq w (+ px (- x w0)) n (+ py (- n0 y)))))
   ((= north "0")
    ;north=0 pdms gives ENU , north=0 pdms gives WNU
    (if (= Xdir "E")
      (setq w (+ px (- n0 y)) n (+ py (- x w0))) (setq w (+ px (- n0 y)) n (+ py (- w0 x)))))
   ((= north "180")
    ;north=180 pdms gives ENU check? , north=180 pdms gives WNU
    (if (= Xdir "E")
      (setq w (+ px (- y n0)) n (+ py (- w0 x))) (setq w (+ px (- y n0)) n (+ py (- x w0)))))
   ((= north "270")
    ;north=270 pdms gives ENU check? , north=270 pdms gives WNU check?
    (if (= Xdir "E")
     (setq w (+ px (- x w0)) n (+ py (- y n0))) (setq w (+ px (- w0 x)) n (+ py (- y n0)))))
 )
 ;insertion point for instrument
 (setq pt (list w n))   
)
;---------------------------------------------
;plots and labels the tags
(Defun pltag  (/ p2 p3)
 (command "ortho" "off")
 (setq p2 (list (car pt) (+ (cadr pt) (* sc 20)) 0))
 (command "insert" "Dot" pt sc sc 0)
 (setq p2 (getpoint pt "\nSelect first point of leader line:"))
 (command "layer" "set" "INLEAD-5" "")
 (command "line" pt p2 "")
 (command "ortho" "on")
 (if (= ynk "Y") (setq p3 p2) (setq p3 (getpoint p2 "\nSelect next point:")))
 (setq p4 p3)
 (if (= ynk "N") (command "pline" pt "w" 0 0 p2 p3 ""))
 (command "layer" "set" "INSYM-1" "")
 (if (> (car p2) (car p3))
   (progn (setq sym (strcat sym "_Left")) (command "insert" sym p3 sc sc 0 TNumber))
   (progn (setq sym (strcat sym "_Right")) (command "insert" sym p3 sc sc 0 TNumber))
 )
)
;---------------------------------------------
; Load the icplot function automatically
(icplot)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×