;;;    Archivo          : TRAZAR.LSP
;;;    Programador      : Jose M. Ruben Paz
;;;    Fecha            : setiembre 2003 
;;;    Revision	     	: marzo 2025	
 	 		
;;;    Este modulo activa el menu de trazar agregado en la instalacion en el directorio
;;;    soporte y carga el programa.  El usuario puede fijar la carpeta en 
;;;    el directorio soporte a traves de la ventana herramientas en opciones.

(defun trazarload (/ filex newpath varcad)
  (setq newpath (strcase (getvar "program")))
  (if (= newpath "BRICSCAD")
    (progn (cond ((null C:READ220)
		  (setq filex "des")
		  (setq varcad "BRICSCAD")
		  (load "trazar.des" "\nTrazar is not loaded")
		 )
	   )
    )
  )
  (if (= newpath "ZWCAD")
    (progn (cond ((null C:READ220)
		  (setq filex "vlx");;ZWCAD NEAR
		  (setq varcad "ZWCAD")
		  (load "trazar.vlx" "\nTrazar is not loaded")
		 )
	   )
    )
  )
 (if (= newpath "GCAD")
    (progn (cond ((null C:READ220)
		  (setq filex "vlx")
		  (setq varcad "GCAD")
		  (load "trazar.vlx" "\nTrazar is not loaded")
		 )
	   )
    )
  )
  (if (= newpath "ICAD")
    (progn (cond ((null C:READ220)
		  (setq filex "vlx")
		  (setq varcad "ICAD")
		  (load "trazar.vlx" "\nTrazar is not loaded")
		 )
	   )
    )
  )
  (if (or (= newpath "ACAD") (= newpath "ACADLT"))
    (progn (cond ((null C:READ220)
		  (setq filex "vlx")
		  (setq varcad "ACAD")
		  (load "trazar.vlx" "\nTrazar is not loaded")
		 )
	   )
    )
  )
  (setq #filex15 filex)
  (setq #varcad15 varcad)
)
(defun prefixpath (/ MAINPATH MARTAP TESTNAME TESTPATH )
  (setq mainpath "NONE")
  (setq testname "NONE")
  (setq testpath (getvar "dwgprefix"))


  (if (/= testpath nil)
    (progn
      (if (/= (wcmatch (strcase testpath) "*TRAZAR-COLLECTIONS*") T);;cualquier carpeta
	(progn
	  (setq testpath nil)
;;;legaci
	)
      )
      ;;if
    )
  )


  (setq testname (getvar "dwgname"))
  (if (= testname "trazar.dwg")			;,cualquier dibujo en carpeta
    (progn

  (setq martap (strcase (getvar "program")))
  (if (/= (wcmatch (strcase (getenv martap)) "*TRAZAR-COLLECTIONS*")
	  T
      )
    (setenv martap (strcat (getenv martap) ";" testpath))
  )
   ;;; (princ "\n*** Add path to support path ***")
      (princ)
    )
  )
  (princ)
)					;defun
(defun installpath (/ count1 count2 count3 count4 count5 filex newpath pathfolder mainfile)
  (setq newpath nil)
  (setq filex #filex15)
  (setq varcad #varcad15)
  (setq #namedir "trazar-collections");;carpeta
  (setq #bardir "\\")

  (setq mainfile (strcat "trazar" "." filex))
  (if (= (wcmatch (strcase (getvar "platform")) "*LINUX*") T)(progn
  (setq #bardir "/");;compatibilidad windows-linux directory
  )) ;; linux;;if

 (setq	pathfolder
	 (vl-registry-read
	   "HKEY_CURRENT_USER\\software\\Trazar Technologies PAN\\trazar"
	   "pathfolder"
	 )
  )
 (if (/= pathfolder nil)(progn
  (if (= (wcmatch (strcase pathfolder) "*TRAZAR-SUITE-TOOLS*") T)(progn
  (setq pathfolder nil);;;legaci
  ));;if
  ))

 (if (= pathfolder nil)(setq newpath (findfile "trazar.lsp")))
 (if (/= newpath nil)
	 (progn
	   (setq count1 (strlen newpath))
	   (setq count2 (strlen "trazar.lsp"))
	   (setq count3 (- count1 (+ count2 1)))
	   (setq count4 (substr newpath 1 count3))
           (setq pathfolder count4)
  ))
  (if (or (= pathfolder nil)(/= (type pathfolder) 'STR))
  (progn
  (setq pathfolder (getvar "mydocumentsprefix"));;; getuser document 
  (if (and (/= pathfolder nil)(= (type pathfolder) 'STR))
  (setq pathfolder (strcat pathfolder #bardir #namedir #bardir ))
  );;if
  ));if

  (if (and (/= pathfolder nil)
	   (= (type pathfolder) 'STR)
	   (/= (wcmatch (getenv varcad) (strcat "*" pathfolder "*"))
	       T
	   )
      )
    (progn
      (setenv varcad (strcat (getenv varcad) ";" pathfolder))
    )
  )
  (prompt "\nTrazar is loading application !!!")
 (load mainfile "\nTrazar is not loaded")
)					;,defun
(defun userpath	(/	   filex     count1    count2	 count3
		 count4	   count5    mainfile  mainpath	 newpath
		)
  (setq mainpath "NONE")
  (setq filex #filex15)

  (progn
    (cond
      ((null (findfile "trazar.lsp"))
       (if (= filex "vlx")
	 (setq newpath (getfiled "Select the Trazar Directory ..." 
				 "appz"
				 "cuix"
				 8
		       )
	 )
       )
       (if (= filex "des")
	 (setq newpath (getfiled "Select the Trazar Directory ..." 
				 "appz"
				 "cuix"
				 8
		       )
	 )
       )
     (if (= filex "vlxtmp");;ZWCAD NEAR;;futuro uso
	 (setq newpath (getfiled "Select the Trazar Directory ..." 
				 "appz"
				 "cuix"
				 8
		       )
	 )
       )
       (setq mainfile (strcat "TRAZAR" "." filex))
       (setq mainfile "appz.cuix")
       (if (/= newpath nil)
	 (setq newpath (strcat newpath))
       )
       (if (/= newpath nil)
	 (progn
	   (setq newpath (strcase newpath))
	   (setq count1 (strlen newpath))
	   (setq count2 (strlen mainfile))
	   (setq count3 (- count1 (+ count2 1)))
	   (setq count4 (substr newpath 1 count3))
	   (setq count5 (substr newpath (+ count3 2) count1))
	   (setq mainpath count5)
	 )
       )
       (if (= (strcase mainpath) (strcase mainfile))
	 (progn (setenv varcad (strcat (getenv varcad) ";" count4)))
       )
       (if (/= newpath nil)
	 (progn
	   (prompt "\nTrazar is loading application !!!")
           (setq newpath (strcat "trazar" "." filex))
	   (load newpath)
	   (progn
	     (cond ((null C:READ220)
		    (prompt "\nTrazar esta parcialmente cargado !!!")
		   )
	     )
	   )
	 )
       )
       (progn
	 (cond ((null newpath)
		(prompt "\nTrazar esta parcialmente cargado !!!")
	       )
	 )
       )				;progn
      )
    )					;cond
  )					;progn
  (princ)
)					;defun
;;; prefix dwg
(progn (cond ((null (findfile "trazar.lsp")) (prefixpath))));;first here
;;; load source
(trazarload)
(progn (cond ((null (findfile "trazar.lsp")) (vl-load-com))))
(progn (cond ((null (findfile "trazar.lsp")) (installpath))))
(progn (cond ((null (findfile "trazar.lsp")) (userpath))))

(princ)


