Jump to content

Lisp for Automatic Draw Order Command to a specific Layer.


Recommended Posts

Posted

Hello,

 

I was wondering if anybody could help me as I have no knowledge of AutoLisp.

 

Does anybody have a lisp command that allows me to put my "dims" layer to the back of the drawing when it is inserted ( i have it set up so that when i insert a dimension it is automatically assigned to the "dims" layer. )

 

This is so I don't always have to use the draw order command to move the "dim" layer to the back.

 

Also, if someone does have it handy, how do you load it? lol...

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    12

  • ichlove

    9

  • wizman

    3

  • matinau

    2

Posted

Just asking, why would you need to have your dims in a different draworder?

  • 2 weeks later...
Posted

Did you have found the solution ???

 

I need to do the same thing for x-ref.

I have problem with the plotter PDF995. He does'nt merge line. So I have to make a patch

I have to do a draw order before each plotting.

Posted

Here is some code that takes the "dims" layer and moves all the objects on it to the back.

 

;; Moves all objects on the "dims" layer to the back
(defun c:layerback()
;; creates a selection set of all objects on the "dims" layer.
 (setq sel1 (ssget "x" '((8 . "dims"))))
;; Uses the draworder command to move the objects to the back
 (command "draworder" sel1 "" "back")
)

 

To use this code open autocad and go to the following menus

 

Tools -> AutoLISP -> AutoLISP Editor

 

This will open an editor. Choose the File -> New File menu then paste the code into the window. Save the file by some meaningful name anywhere you want.

 

Now you can close the editor and go back to AutoCAD. Go to

 

Tools -> AutoLISP -> Load Application...

 

and select the file name you just saved. This is all you have to do once you've saved it. You can see from the code that the name of the command is layerback. Just type layerback into the command line and it will move all objects on the "dims" layer to the back.

 

I chose to keep the code simple so you could understand what's going on and maybe make some adjustments as needed.

Posted

Thanks for that Bucingham, Exactly what I have been looking for.

Cheers.

 

Minnes, I downloaded a pdf writr called Bullzip PDF. I found that it works alot better than 995, You should try it.

Posted

Thanks, Stevsmith, but Bullzip Pdf does'nt work. :(

I found Acropolt et UDC. These two converter work well, but there are expensive

So I have to do a patch to solve this problem

 

Patch =

Each time we select plot

Go in pspace

Choose all xrefs who have a "a" for the fourth letter

Send these xrefs back (draworder)

Go back in mspace

Open plot dialogue box

 

I dont knok if I have to do a lisp or VBA?

  • 6 months later...
Posted

Hi ,

 

How can I make it works in a block?

 

tks

Here is some code that takes the "dims" layer and moves all the objects on it to the back.

 

;; Moves all objects on the "dims" layer to the back
(defun c:layerback()
;; creates a selection set of all objects on the "dims" layer.
 (setq sel1 (ssget "x" '((8 . "dims"))))
;; Uses the draworder command to move the objects to the back
 (command "draworder" sel1 "" "back")
)

To use this code open autocad and go to the following menus

 

Tools -> AutoLISP -> AutoLISP Editor

 

This will open an editor. Choose the File -> New File menu then paste the code into the window. Save the file by some meaningful name anywhere you want.

 

Now you can close the editor and go back to AutoCAD. Go to

 

Tools -> AutoLISP -> Load Application...

 

and select the file name you just saved. This is all you have to do once you've saved it. You can see from the code that the name of the command is layerback. Just type layerback into the command line and it will move all objects on the "dims" layer to the back.

 

I chose to keep the code simple so you could understand what's going on and maybe make some adjustments as needed.

Posted

Do you mean change the order of the nested entities inside a block?

Posted

Hi,

 

When I use layer back,it only works on the object out of the block.Maybe would be more clear see the attached small smaple.

 

And it would be better that can make layer draw order automatically,like helpline will be always the bottom one,intenral wall the second one ,structure always the above,etc.

tks

sample.dwg

Posted

Ohh, thats a tough one - maybe someone else with a bit more knowledge on this can help :oops:

Posted

Hi,

 

How about just make draworder,like layer 1 above layer 2;layer 2 above layer 3,layer 3 above layer 4,etc.can you help me to make this ?

 

thanks

Posted

Not sure if this would do it?

 

(defun c:orderlay (/ laylist ss)
 (vl-load-com)
 (vlax-for layer
       (vla-get-layers
         (vla-get-ActiveDocument
       (vlax-get-Acad-Object)))
   (setq laylist (cons (vla-get-name layer) laylist)))
 (foreach lay (reverse laylist)
   (if (setq ss (ssget "X" (list (cons 8 lay))))
     (command "_draworder" ss "" "_B")))
 (princ))

Posted

Hi,can I choose layer name by myself,maybe we needn't take all the layer since we have 50 layer.maybe can just set 10 layers first.(you can just write layer 1,layer 2,layer3 ,ect first,later I can replace our layer name)

 

Thanks

Posted

It is difficult to "order" layers imo - in the LISP routine above, I just send each layer to the back consecutively, so that they are "ordered".

Posted

I see,then can you also add into send each layer to the front consecutively?thanks

Posted

I suppose this?

 

(defun c:orderlay  (/ laylist ss)

 (setq laylist '("LAYER1"  ;  <---<< List Layers Here.
                 "LAYER2"
                 "LAYER3"
         ))
 
 (foreach lay laylist
   (if    (and (tblsearch "LAYER" lay)
        (setq ss (ssget "X" (list (cons 8 lay)))))
     (command "_draworder" ss "" "_F")))
 (princ))

Posted

Yes!that's one we want,but I guess it's hard to make it works in the block?:unsure:

Posted

Well, yes, as I said earlier, draw order is a bit of a funny thing to play around with, I have no idea how to make it work within blocks :(

 

Sorry

Posted

Hi Lee Mac.

 

Sorry,one more request!Is that possible make the lisp run automatically without use the command,means everytime when I draw a line,the computer will help me to make the draw order,and if I make any manual change about the order,it will stay my manual change.

 

thanks

Posted
Hi Lee Mac.

 

Sorry,one more request!Is that possible make the lisp run automatically without use the command,means everytime when I draw a line,the computer will help me to make the draw order,and if I make any manual change about the order,it will stay my manual change.

 

thanks

 

You could use a reactor I suppose, but then in my posted function, I have used command calls, which aren't good to use with reactors...

 

but, if someone can work out how to alter draw-order without resorting to command calls, then, yes, it is possible.

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