Guest kruuger Posted June 6, 2010 Share Posted June 6, 2010 Hello I create a simple lisp routine to freeze required layer in viewport. Everything works fine but when we got a lot of layers and xref's programs not works to fast. sometimes it takes more then 10sec to finish. Is there any way to speed up this routine? Change some functions, maybe do this in completely different way? Any ideas? thanks kruuger Scale VP.lsp Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 7, 2010 Share Posted June 7, 2010 Try to access layer's associated lists and modify parameters instead of using command function. Regards, Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 7, 2010 Share Posted June 7, 2010 Try to access layer's associated lists and modify parameters instead of using command function. Regards, hmm, i'm not sure if i understood you correct? do you mean (vla-put-freeze aNewLayer :vlax-true)? i think i can't use this because it freeze layer in drawings not in selected vport. I try also with XDATA code 1003 for vport, but entmode can't update the viewport. kruuger Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 7, 2010 Share Posted June 7, 2010 If you are stuck with command, put the layers into a comma delimited string so you only have to execute VPLayer once. Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 8, 2010 Share Posted June 8, 2010 If you are stuck with command, put the layers into a comma delimited string so you only have to execute VPLayer once. i'm not sure this will help because i want to freeze all layers *dims* and *text* (use mask for that). krugger Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 i'm not sure this will help because i want to freeze all layers *dims* and *text* (use mask for that). krugger Then use "*dims*,*text*" Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 8, 2010 Share Posted June 8, 2010 Then use "*dims*,*text*"aaa like this...i will try this tomorrow at work. thanks kruuger Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 aaa like this...i will try this tomorrow at work. thanks kruuger Good luck.:wink: Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 9, 2010 Share Posted June 9, 2010 oo yes, it works faster. but i noticed one thing. at beginning i freeze these layers: "*DIM*,*TEXT_*,A-HAT1*,*veneer*" after that i restore, for example for scale 3" layer *veneer*. restoring takes a lot of time so... my idea is only to freeze and not restore. but how to not freeze, for example for scale 16 layer *DIM16*,*TEXT_16? is it possible to do this with wcmatch? (freeze *DIM* but exclude *DIM16*) thanks kruuger Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 10, 2010 Share Posted June 10, 2010 Try something like this: (defun _LayerFilter (include exclude / d s) ;; include - filter string to include matching ("" if not needed) ;; exclude - filter string to exclude matching ("" if not needed) ;; Alan J. Thompson (while (setq d (tblnext "layer" (null d))) (if (and (wcmatch (setq d (strcase (cdr (assoc 2 d)))) (strcase include)) (not (wcmatch (strcase d) (strcase exclude))) ) (if s (setq s (strcat s "," d)) (setq s d) ) ) ) s ) eg. (_layerfilter "*dim*" "*dim16*") Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 15, 2010 Share Posted June 15, 2010 Alan your code works perfect. now wihtout restoring layers lisp should work very fast. thank you, kruuger Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 15, 2010 Share Posted June 15, 2010 Alan your code works perfect. now wihtout restoring layers lisp should work very fast. thank you, kruuger You're welcome. Enjoy. Quote Link to comment Share on other sites More sharing options...
Se7en Posted June 16, 2010 Share Posted June 16, 2010 Maybe someone can help you incorporate something along the lines of entmod or vla-put-freeze so you dont have to use command at all (not that command is bad; I use it quite a bit myself)...you know, for fun. Here is a small (funny *lol*) example of how you can freeze the current layer using entmod by just quickly flipping a bit. ( (lambda ( / laylst ) (setq laylst (entget (tblobjname "LAYER" (getvar 'CLAYER)))) (entmod (subst (cons 70 (boole 6 (cdr (assoc 70 laylst)) 1)) (assoc 70 laylst) laylst))) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 16, 2010 Share Posted June 16, 2010 Nice one Se7en, this is what I had: ;; Freeze/Thaw Layer ~ Lee Mac ;; layer - layer table object (tblobjname) ;; freeze - 1 = Freeze Layer ;; 0 = Thaw Layer (defun FTLayer ( layer freeze / dx70 el ) (setq dx70 (cdr (assoc 70 (setq el (entget layer))))) (entmod (subst (cons 70 (boole (+ 4 (* freeze 3)) 1 dx70)) (assoc 70 el) el))) Quote Link to comment Share on other sites More sharing options...
Se7en Posted June 16, 2010 Share Posted June 16, 2010 *smile* Also very nice. Too bad I only have one more trick up my sleeve. What if we improve the argument handling ability of our little concoction? ;; Argument: ;; t or non nil: thaw, or leave thawn ;; 0 or false: freeze, or leave frozen ;; Any value except 0 = true (cond ((= 0 argument) 7) (argument 2) (7)) (defun frlay ( argument / laylst ) ;; Argument: ;; t or non nil: thaw, or leave thawn ;; 0 or false: freeze, or leave frozen ;; Any value except 0 = true (setq laylst (entget (tblobjname "LAYER" (getvar 'CLAYER)))) (entmod (subst (cons 70 (boole (cond ((= 0 argument) 7) (argument 2) (7)) (cdr (assoc 70 laylst)) 1)) (assoc 70 laylst) laylst))) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 17, 2010 Share Posted June 17, 2010 Se7en, Lee Please noticed that my goal was to freeze layer thru viewport. Only way i know is vplayer. kruuger Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 20, 2010 Share Posted June 20, 2010 Try this Kruuger: ;; Freeze Layer in Viewport (Lee Mac) ;; Arguments: ;; layername [sTR] ~ valid Layer Name ;; flag [iNT] ~ 1 = freeze in vp ;; 0 = thaw in vp (defun FreezeInViewport ( layername flag ) ;; © Lee Mac ~ 20.06.10 ( (lambda ( object ) (if object (entmod (subst (cons 70 (boole (+ (* flag 5) 2) (cdr (assoc 70 (entget object) ) ) 2 ) ) (assoc 70 (entget object)) (entget object) ) ) ) ) (tblobjname "LAYER" layername) ) ) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 20, 2010 Share Posted June 20, 2010 Try this Kruuger: ;; Freeze Layer in Viewport (Lee Mac) ;; Arguments: ;; layername [sTR] ~ valid Layer Name [sTR] ;; flag [iNT] ~ 1 = freeze in vp ;; 0 = thaw in vp (defun FreezeInViewport ( layername flag ) ;; © Lee Mac ~ 20.06.10 ( (lambda ( object ) (if object (entmod (subst (cons 70 (boole (+ (* flag 5) 2) (cdr (assoc 70 (entget object) ) ) 2 ) ) (assoc 70 (entget object)) (entget object) ) ) ) ) (tblobjname "LAYER" layername) ) ) hmm, nothing happen. is missing something for object? kruuger Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 20, 2010 Share Posted June 20, 2010 What was the return? How did you call it? Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 20, 2010 Share Posted June 20, 2010 return: Command: (FREEZEINVIEWPORT "DRAWER3" 0) ((-1 . <Entity name: 7c7bb798>) (0 . "LAYER") (330 . <Entity name: 7ec41c10>) (5 . "2B23") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "DRAWER3") (70 . 0) (62 . 3) (6 . "Continuous") (290 . 1) (370 . -3) (390 . <Entity name: 7ec41c78>) (347 . <Entity name: 7ec41f00>)) Command: (FREEZEINVIEWPORT "DRAWER3" 1) ((-1 . <Entity name: 7c7bb798>) (0 . "LAYER") (330 . <Entity name: 7ec41c10>) (5 . "2B23") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "DRAWER3") (70 . 2) (62 . 3) (6 . "Continuous") (290 . 1) (370 . -3) (390 . <Entity name: 7ec41c78>) (347 . <Entity name: 7ec41f00>)) any difference is for code 70. k. 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.