CAD/CAM discussion forum > CAD > ZWCAD take long time to make layer by lisp

ZWCAD take long time to make layer by lisp

Rank: 1

Atabey37

Newbie

posts: 0

Registered: 2011-12-1

Message 1 of 7

 ZWCAD take long time to make layer by lisp
03-03-2011 07:12 . pm | View his/her posts only
hi

(COMMAND "LAYER" "MAKE" "1" "COLOR" "1" "" "" )

why this command take very long time in lsp file!!!

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 2 of 7

03-03-2011 07:12 . pm | View his/her posts only
Dear Atabey,

I tried this code in lsp file, it works fast in 2010 and 2011 version.

May I know what is your ZWCAD version?

Also, I think this may be one sentence in your lsp file, so could you send us the whole lsp file that containing this line which works slow?
Thanks, our email is tech@zwcad.com

Rank: 1

Atabey37

Newbie

posts: 0

Registered: 2011-12-1

Message 3 of 7

04-03-2011 07:52 . am | View his/her posts only


Dear Daniel,


i use ZWCAD 2011 Pro trial version.

and this lisp work very slow in big files..( over 2 MB dwg files)
(this lisp work fast little files)

but same lisp fast work on autocad even big files ( over 2 MB dwg files)

(DEFUN C:ZZ ( / )

(COMMAND "LAYER" "MAKE" "0" "COLOR" "0" "" "")
(COMMAND "LAYER" "MAKE" "1" "COLOR" "1" "" "")
(COMMAND "LAYER" "MAKE" "2" "COLOR" "2" "" "")
(COMMAND "LAYER" "MAKE" "3" "COLOR" "3" "" "")
(COMMAND "LAYER" "MAKE" "4" "COLOR" "4" "" "")
(COMMAND "LAYER" "MAKE" "5" "COLOR" "5" "" "")
(COMMAND "LAYER" "MAKE" "6" "COLOR" "6" "" "")
(COMMAND "LAYER" "MAKE" "7" "COLOR" "7" "" "")
(COMMAND "LAYER" "MAKE" "8" "COLOR" "8" "" "")
(COMMAND "LAYER" "MAKE" "9" "COLOR" "9" "" "")
(COMMAND "LAYER" "MAKE" "12" "COLOR" "12" "" "")
(COMMAND "LAYER" "MAKE" "30" "COLOR" "30" "" "")
(command "COLOR" "BYLAYER")
)

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 4 of 7

07-03-2011 06:44 . pm | View his/her posts only
Hi, as we talkedonline, this lisp file do work slow in big drawings, you can change all your lines to :
(entmake '((0 . "Layer")(2 . "1")(62 . 1))) ;;(COMMAND "LAYER" "MAKE" "1" "COLOR" "1" "" "")

It will definately improve the speed of execution. Thanks

Rank: 1

Atabey37

Newbie

posts: 0

Registered: 2011-12-1

Message 5 of 7

09-03-2011 08:32 . am | View his/her posts only


hi m8 there is a problem your code!!!


not equal this code my code!!

if there is layer "1" your code dont work...

for exp :

your drawing there is Layer "1" and layer color "5"
your code cant chage it
but my code change it !!!

m

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 6 of 7

10-03-2011 01:42 . am | View his/her posts only


Hi, thanks for the feedback.


We changed the code again, here like this:
;;(COMMAND "LAYER" "MAKE" "1" "COLOR" "1" "" "")
(if (tblsearch "layer" "1")
(mlayercolor "1" "1")
(entmake '((0 . "Layer") (2 . "1") (62 . 1)))
)

We also add another function outside ZZ:

(defun mlayercolor (layername layercolor / alllayer layerqua step stepflag layerobj)

(setq alllayer (vlax-get-property(vla-get-activedocument (vlax-get-acad-object)) 'layers))
(setq layerqua (vlax-get-property alllayer 'count))
(setq step 0 stepflag T)

(while (and (< step layerqua) stepflag)
(setq layerobj (vlax-invoke-method alllayer 'item step))
(if (= layername (vlax-get-property layerobj 'name))
(progn
(vlax-put-property layerobj 'color (atoi layercolor))
(setq stepflag NIL)
)
)
(setq step (+ step 1))
)
)


Add this part at the end of the lsp file. and have a try~

Rank: 1

jemesright

Newbie

posts: 0

Registered: 2012-1-6

Message 7 of 7

20-08-2011 07:42 . am | View his/her posts only
The Layer command is used to control the appearance of objects. It organizes your drawing by grouping objects with similar properties or themes together.


A layer is a transparent overlay that makes locating, viewing and editing objects allot easier by improving drawing efficiency and accuracy.
See also