Jump to content

Recommended Posts

Guest kruuger
Posted

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

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    12

  • Lee Mac

    6

  • Se7en

    2

  • MSasu

    1

Top Posters In This Topic

Posted

Try to access layer's associated lists and modify parameters instead of using command function.

 

Regards,

Guest kruuger
Posted
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

Posted

If you are stuck with command, put the layers into a comma delimited string so you only have to execute VPLayer once.

Guest kruuger
Posted
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

Posted
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*"
Guest kruuger
Posted
Then use "*dims*,*text*"
aaa like this...

i will try this tomorrow at work.

 

thanks

kruuger

Posted
aaa like this...

i will try this tomorrow at work.

 

thanks

kruuger

Good luck.:wink:

Guest kruuger
Posted

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

Posted

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*")

Guest kruuger
Posted

Alan your code works perfect. now wihtout restoring layers lisp should work very fast.

 

thank you,

kruuger

Posted
Alan your code works perfect. now wihtout restoring layers lisp should work very fast.

 

thank you,

kruuger

 

You're welcome. Enjoy. :)

Posted

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

Posted

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

Posted

*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)))

Guest kruuger
Posted

Se7en, Lee

 

Please noticed that my goal was to freeze layer thru viewport.

Only way i know is vplayer.

 

kruuger

Posted

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

Guest kruuger
Posted
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

Guest kruuger
Posted

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.

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