Jump to content

Specify Path of Linetype


Guest

Recommended Posts

Hi, i want load my linetypes from topo.lin file. Here is my code.

 

(DEFUN
  C:fen (/ A1 KLIM PER S1 S2 SCL)
 (COMMAND "_layer" "_m" "fen" "_c" "140" "" "_LT" "" "C:\\topocad\\topo.lin\\fen" "")
 (SETQ SCL (GETVAR "useri1"))
 (SETQ KLIM (* 0.005 SCL))
 (SETQ PER "Fen")
 (COMMAND "_linetype" "_s" "C:\\topocad\\topo.lin\\fen" "")
 (PRINT "")
 (SETQ S1 (GETPOINT "give the first point :"))
 (PRINT "")
 (WHILE (SETQ S2 (GETPOINT S1 " give the second point:"))
   (PRINT "")
   (COMMAND "_line" "non" S1 "non" S2 "")
   (COMMAND "_CHPROP" (ENTLAST) "" "_S" KLIM "")
   (SETQ S1 S2)
 )
)

 

when i run the code gives me this result

 

; error: Function cancelled

Specify linetype name or [?] :

 

Can you help?

Thanks

Link to comment
Share on other sites

I think that you missed to specify what linetype to load:

(COMMAND "_linetype" [color=red]"_L"[/color] [color=red]"NameOfYourLIneType"[/color] "C:\\topocad\\topo.lin\\fen[color=red].lin[/color]" "")

To make that current, may want to check CELTYPE system variable, too.

Link to comment
Share on other sites

Try this :

 

(DEFUN C:fen ( / A1 KLIM S1 S2 SCL )
 (COMMAND "_.-linetype" "_L" "fen" "C:\\topocad\\topo.lin")
 (COMMAND "_.-layer" "_m" "fen" "_c" "140" "" "_LT" "fen" "" "")
 (SETQ SCL (GETVAR "useri1"))
 (SETQ KLIM (* 0.005 SCL))
 (PRINT "")
 (SETQ S1 (GETPOINT "give the first point :"))
 (PRINT "")
 (WHILE (SETQ S2 (GETPOINT S1 " give the second point:"))
   (PRINT "")
   (COMMAND "_.line" "non" S1 "non" S2 "")
   (COMMAND "_.change" (entlast) "" "_P" "_LT" "fen" "_S" KLIM "")
   (SETQ S1 S2)
 )
 (PRINC)
)

Link to comment
Share on other sites

marko_ribar now gives me this

 

Command: (LOAD "C:/Users/Prodromos/Desktop/fen.lsp") C:FEN

Command: fen

_.-linetype

Current line type: "ByLayer"

Enter an option [?/Create/Load/Set]: _L

Enter linetype(s) to load: fen Enter name of linetype file to search

: C:\topocad\topo.lin

Linetype "fen" is already loaded. Reload it? _.-layer

Yes or No, please.

; error: Function cancelled

Linetype "fen" is already loaded. Reload it?

Link to comment
Share on other sites

Something like this perhaps.

(DEFUN C:fen (/ A1 KLIM OLD_CLT PER S1 S2 SCL)
 (setq old_clt (getvar 'CELTYPE))
 (if (and (not (tblsearch "ltype" "fen"))
   (findfile "C:\\topocad\\topo.lin")
     )
   (command "-linetype" "l" "fen" "C:\\topocad\\topo.lin" "")
 )
 (if (tblsearch "ltype" "fen")
   (progn
     (COMMAND "_layer" "_m" "fen" "_c" "140" "fen" "_lt" "fen" "fen" "")
     (SETQ SCL (GETVAR "useri1"))
     (SETQ KLIM (* 0.005 SCL))
     ;; (SETQ PER "Fen") ?????
     (COMMAND "_linetype" "_s" "fen" "")
     ;;(PRINT "")
     (SETQ S1 (GETPOINT "\nSpecify the first point :"))
     ;;(PRINT "")
     (WHILE (SETQ S2 (GETPOINT S1 "\nSpecify the second point:"))
;;(PRINT "")
(COMMAND "_line" "non" S1 "non" S2 "")
(COMMAND "_CHPROP" (ENTLAST) "" "_S" KLIM "")
(SETQ S1 S2)
     )
     (setvar 'CELTYPE old_clt)
   )
 )
 (princ)
)

 

HTH

Henrique

Link to comment
Share on other sites

Can any one add an option at the end of this lisp

 

You want to convert this line to polyline Y/N

 

(DEFUN C:fen (/ A1 KLIM OLD_CLT PER S1 S2 SCL)
 (setq old_clt (getvar 'CELTYPE))
 (if (and (not (tblsearch "ltype" "fen"))
   (findfile "C:\\topocad\\topo.lin")
     )
   (command "-linetype" "l" "fen" "C:\\topocad\\topo.lin" "")
 )
 (if (tblsearch "ltype" "fen")
   (progn
     (COMMAND "_layer" "_m" "fen" "_c" "140" "fen" "_lt" "fen" "fen" "")
     (SETQ SCL (GETVAR "useri1"))
     (SETQ KLIM (* 0.005 SCL))
     ;; (SETQ PER "Fen") ?????
     (COMMAND "_linetype" "_s" "fen" "")
     ;;(PRINT "")
     (SETQ S1 (GETPOINT "\nSpecify the first point :"))
     ;;(PRINT "")
     (WHILE (SETQ S2 (GETPOINT S1 "\nSpecify the second point:"))
;;(PRINT "")
(COMMAND "_line" "non" S1 "non" S2 "")
(COMMAND "_CHPROP" (ENTLAST) "" "_S" KLIM "")
(SETQ S1 S2)
     )
     (setvar 'CELTYPE old_clt)
   )
 )
 (princ)
)

 

(initget "Yes No")
  (setq convert (cond ( (getkword "\nConvert to polylines? [Yes/No] <Y>: ") ) ( "Yes" )))
         (if ( "Yes" convert)
             (command "_.pedit" "_M"   "" "_J" "" ""))
         )

 

I dont know how to conect them

thanks

Link to comment
Share on other sites

Since the routine is drawing only one segment, why don't create that as polyline directly?

(COMMAND "_[color=magenta]P[/color]line" "non" S1 "non" S2 "")

Link to comment
Share on other sites

Something like this perhaps

(DEFUN C:fen (/ CONVERT KLIM OLD_CLT S1 S2 SCL SS)
 (setq old_clt (getvar 'CELTYPE))
 (if (and (not (tblsearch "ltype" "fen"))
   (findfile "C:\\topocad\\topo.lin")
     )
   (command "-linetype" "l" "fen" "C:\\topocad\\topo.lin" "")
 )
 (if (tblsearch "ltype" "fen")
   (progn
     (setq ss (ssadd))
     (COMMAND "_layer" "_m" "fen" "_c" "140" "fen" "_lt" "fen" "fen" "")
     (SETQ SCL (GETVAR "useri1"))
     (SETQ KLIM (* 0.005 SCL))
     (COMMAND "_linetype" "_s" "fen" "")
     (SETQ S1 (GETPOINT "\nSpecify the first point :"))
     (WHILE (SETQ S2 (GETPOINT S1 "\nSpecify the second point:"))
(COMMAND "_line" "non" S1 "non" S2 "")
(COMMAND "_CHPROP" (ENTLAST) "" "_S" KLIM "")
(ssadd (ENTLAST) ss)
(SETQ S1 S2)
     )
     (setvar 'CELTYPE old_clt)
     (initget "Yes No")
     (if (and (setq
  convert (cond
     ((getkword "\nConvert to polylines? [Yes/No] <Y>: "))
     ("Yes")
   )
       )
       (/= (sslength ss) 0)
       (= convert "Yes")
  )
(if (= (getvar 'PEDITACCEPT) 0)
  (command "_.pedit" "_M" ss "" "_Y" "_J" "" "")
  (command "_.pedit" "_M" ss "" "_J" "" "")
)
     )
   )
 )
 (princ)
)

 

HTH

Henrique

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...