Jump to content

lisp make layer manager current filter ALL


CAD

Recommended Posts

The code in that thread doesn't solve completely your issue, it rather finds how a property filter is created, which could help for your future code.

Please attach a sample drawing to test, cause theres also a question do you use "Properties" or "Group" filter.

Link to comment
Share on other sites

I use this:

 

Executes the command on load of the LSP file:

(defun SETLAYERFILTER ( / )
(setvar "cmdecho" 0)
(command "UNDO" "BEGIN")
(setq i 0)
(vlax-for x (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))(if (eq (vla-get-IsXref x) :vlax-true)(setq i (1+ i))))
(if (>= i 1)(command "-Layer" "Filter" "Set" "All non-Xref Layers" ""))
(command "UNDO" "END")
(setvar "cmdecho" 1)
(princ)
)

(SETLAYERFILTER)

 

Regular command:

(defun C:SETLAYERFILTER ( / )
(setvar "cmdecho" 0)
(command "UNDO" "BEGIN")
(setq i 0)
(vlax-for x (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))(if (eq (vla-get-IsXref x) :vlax-true)(setq i (1+ i))))
(if (>= i 1)(command "-Layer" "Filter" "Set" "All non-Xref Layers" ""))
(command "UNDO" "END")
(setvar "cmdecho" 1)
(princ)
)

 

When there is a XreF present in the DWG file, AutoCAD auto-creates the layer filter.

This command checks if there are XREF's, if so... the filter is also present and thus its set.

Link to comment
Share on other sites

@Aftertouch good efforts.

 

I just wanted to pay your attention to an important issue that you may would like to know and to learn from is that since your aim in iteration of Block table is to know if there is any External Reference existed into current drawing then it would be a very good idea to stop iterating though the rest of blocks inside the drawing to get your function working efficiently and faster.

 

Beside that, coding with DXF as long as it is possible would be a great idea as well.

 

Please have a look at the following and I am sure that you can get how the codes working.

 

(while (and (not fnd)
           (setq blk (tblnext "BLOCK" (not blk)))
      )
 (and (assoc 1 blk)
      (setq fnd t)
      (command "-Layer" "Filter" "Set" "All non-Xref Layers" "")
 )
)

Link to comment
Share on other sites

@Tharwat, your right.

 

My coding first checks all blocks, and counts all XREF's, where one match would be enough.

Thanks for the hint!

 

You are welcome and keep up the good work. :thumbsup:

Link to comment
Share on other sites

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