pBe Posted October 28, 2010 Share Posted October 28, 2010 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... Quote Link to comment Share on other sites More sharing options...
asos2000 Posted October 28, 2010 Share Posted October 28, 2010 Read this thread May be will be useful Quote Link to comment Share on other sites More sharing options...
pBe Posted October 29, 2010 Author Share Posted October 29, 2010 (edited) 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 October 29, 2010 by pBe double image Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 29, 2010 Share Posted October 29, 2010 (command "_.-linetype" "_load" "*" "acad.lin") (while (eq 1 (logand 1 (getvar 'cmdactive))) (command "")) Quote Link to comment Share on other sites More sharing options...
pBe Posted October 30, 2010 Author Share Posted October 30, 2010 (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? Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 30, 2010 Share Posted October 30, 2010 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? Quote Link to comment Share on other sites More sharing options...
pBe Posted October 30, 2010 Author Share Posted October 30, 2010 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 Quote Link to comment Share on other sites More sharing options...
VVA Posted November 1, 2010 Share Posted November 1, 2010 I want to revisit some of my old codes and convert it to VLISP codss ... Look function _kpblc-linetype-load in post #3 Quote Link to comment Share on other sites More sharing options...
pBe Posted November 2, 2010 Author Share Posted November 2, 2010 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 Quote Link to comment Share on other sites More sharing options...
lamensterms Posted July 10, 2014 Share Posted July 10, 2014 (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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.