Jump to content

"Re-load" Linetype


pBe

Recommended Posts

Hi,

 

With the advent of Annotative Scaling. (Autocad 2009 is new to me thats why..) I've encountered problems with linetype scales. I came up with a lisp which re-loads linetype. I'm not sure why but some of my co-workers mess up the linetype eveytime they touch the drawing. is it because of Annotative scaling?

 

if you look at this code it re-loads linetype via (vl-cmdf....) is it possible to reload linetype using (vl-add ...) and "reload" the linetype? tried it, doesnt appear to work for me and you may notice how the crude way i detect "X-ref/Binded/Custom linetypes" any suggestion how to do this better? and one more query... in cases where you have an xref and the drawing is created in different units.. somehow the linetype on the layer properties shows "Name of the XREF file|Dashed" and i've tried changing it and always comes back to that original name?

 

So as a quick fix i wrote this code

appreciate any help.... thank you

 

(defun c:llt () (vl-load-com)

(setq ddwg (vla-get-activedocument (vlax-get-acad-object))
        ltyps (vla-get-linetypes ddwg) lt_cnt 3 ndflt_cnt1 0 ndflt_cnt2 0)

(setq lts_var  '("MSLTSCALE" "PSLTSCALE" "CELTSCALE" "PLINEGEN")) ; you can change this depending
 (foreach var_lt lts_var      ; on your prefrences......
     (setvar var_lt 1))
(repeat (- (vla-get-count ltyps) 3)
   (setq actv_lt (vla-item ltyps lt_cnt)
       ltname (vla-get-name actv_lt))
 (if  (OR ( = (type (vl-string-search "|" ltname  1)) 'INT) ;Xref Linetype
   ( = (type (vl-string-search "$" ltname  1)) 'INT) ;Binded or CustomLinetype
   ( = (type (vl-string-search " " ltname  1)) 'INT) ;Xref or Custom Linetype
    )(setq ndflt_cnt1 (1+ ndflt_cnt1))
     (chk_wdflt))
   (setq lt_cnt (1+ lt_cnt))
  );repeat

;;;;;;;;;;;;;;;;;;;;;;;;;;; convert to bylayer and ltscale 1
(setq evthng (ssget "x" '((0 . "*LINE,CIRCLE,ARC")))   ;;; idea Lee Mac
      cntr_lt 0)
(while (setq tada (ssname evthng cntr_lt))
   (vla-put-linetype (vlax-ename->vla-object tada) "Bylayer")
   (vla-put-linetypescale (vlax-ename->vla-object tada) 1)
     (setq cntr_lt (1+ cntr_lt)))

(princ (strcat "\n" (itoa ndflt_cnt2)  " Autocad Linetypes Re-loaded"))(princ)
(princ (strcat "\n" (itoa (if 
       (minusp (setq dsvl   
       (- (- (vla-get-count ltyps) 3) ndflt_cnt2))) 0 dsvl)
       )" Xref/Bind/Custom Linetype Name Found"))(princ)

 )
(defun chk_wdflt (/ dfss chk_lt yesness)
(setq dfss (findfile "acad.lin") yesness 'T)
(setq chk_lt (open dfss "R"))
(while yesness  
  (setq dstxt (read-line chk_lt))
   (if (= dstxt nil)(setq yesness nil)
    (progn
     (setq tstr_lt (vl-string-search (vla-get-description actv_lt) dstxt))
      (if tstr_lt (progn (vl-cmdf "linetype" "load" ltname "acad.lin" "y" "")
       (setq yesness nil ndflt_cnt2 (1+ ndflt_cnt2))))   ;prog/if
    );progn
   );if
  );while
(close chk_lt)
)
(prompt
 "\n>>>...Re-load Linetpye Loaded. Type LLT to run...<<<"
)
(princ)


Thank you for the kind words Irneb...:)

Link to comment
Share on other sites

LINETYPE.jpg

Read this thread May be will be useful

 

Good thread :)

 

This is what i mean:

 

 

notice that the liens below each lientype is supposed to be more densed than the one on top. what i wrote is to reload every exisitng linetype. and force it back to its default scale.

 

I used "vl-cmd" or "command"... i tried vl-add / vl-load but nada...

 

I also attache a drawing file of the image

linetype.dwg

Edited by pBe
double image
Link to comment
Share on other sites

(command "_.-linetype" "_load" "*" "acad.lin")
(while (eq 1 (logand 1 (getvar 'cmdactive))) (command ""))

 

Thanks Allan... but my question is how would you do it using VL-add or vl-load ...... and not thru the command/vl-cmdf

 
(while yesness  
  (setq dstxt (read-line chk_lt))
   (if (= dstxt nil)(setq yesness nil)
    (progn
     (setq tstr_lt (vl-string-search (vla-get-description actv_lt) dstxt))
      (if tstr_lt (progn (vl-cmdf "linetype" "load" ltname "acad.lin" "y" "")
       (setq yesness nil ndflt_cnt2 (1+ ndflt_cnt2))))   ;prog/if
    );progn
   );if
  )

see post #1

 

crude.. really... but it works.. so, is there a way to do it not using command\vl-cmdf?

 

:)

Link to comment
Share on other sites

Simply put, you cannot.

With VLA, you are able to load the linetype definitions, but only if the definition does not already exist. The only possible way would be to change the name of the existing linetype, load the desired linetype, then change everything with the old name linetype to the new one. While this would work, it would take so much effort (digging through block definitions, etc.) that it's just not worth it. Unless you want to venture away from LISP, command is your only option.

 

Out of curiosity, why such an aversion towards the usage anyway?

Link to comment
Share on other sites

Out of curiosity, why such an aversion towards the usage anyway?

 

what i've learned so far from this forum (a great source of knowledge btw, thanks to people like you.. :)) Vlisp functions on some cases are easier to use than good 'ol Autlisp. not that i'm saying its "better" ,i find VLISP's

straightforward approach especially if you need to do a lot of digging really fascinating. being new to VLISP i'm just trying to see if it can do the same thing what Lisp can with less usage of memory and less digging.

 

I want to revisit some of my old codes and convert it to VLISP codss, that is if the process is faster that way , but then again you guys showed me how powerful Lsip really is (lambda, list manipulation...)

 

thank yopu for the info Allan..

really learn a lot from ypou guys :)

Link to comment
Share on other sites

Look function _kpblc-linetype-load in post #3

 

Thank you VVA....

While it does load Linetypes, it doesnt "re-load" the exisitng loaded linetype.... like what alanjit's code does, (maybe i just didint do it right)

 

Well the topic gave me another idea for a a new routine though...

thanks again VVA :)

Link to comment
Share on other sites

  • 3 years later...
(command "_.-linetype" "_load" "*" "acad.lin")
(while (eq 1 (logand 1 (getvar 'cmdactive))) (command ""))

 

Hi Alan,

 

Thanks a lot for this code, it has helped me solve a sticky little issue I have been having with loading linetypes via LISP. Just wondering if the reason you have this code is due to the way ACAD will loop the _.-LINETYPE command if it attempts to load a linetype which is already loaded? That is what I was finding.

 

Thanks again.

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...