Jump to content

Recommended Posts

Posted

Hi all,

I want to activate a desired layer filter when beginning a new dwg or openning an existing dwg file, but calling +LAYER or -LAYER (and Filter->Set options of it) has no effects or causes Fatal Error.

 

Who knows any alternative to set an existing layer filter as active?

 

Note:

 

1- The code which causes Fatal Error is as following:

(command "_.+LAYER" %filter-name% "" "")

 

2- This code has no effect:

(command "_.-LAYER" "_Filter" "_Set" %filter-name% "")

 

Any help or clue is greatly appreciated

Posted

I recall a thread that discussed Layer Filters; if memory serves Lee was able to identify that Layer Filters are contained within a specific Dictionary within the drawing document.

 

HTH

Posted

RenderMan,

I have no difficulty defining a new layer filter. Of course I learned this from Lee, so many thanks to him.

 

My problem is just activating an existing layer filter via VLISP code.

Posted
My problem is just activating an existing layer filter via VLISP code.

 

To my knowledge, I don't believe this functionality was ever exposed to the AutoLISP / Visual LISP API - one can define a new layer filter by creating the necessary Dictionary and XRecord entries, however, I see no way to set a layer filter to be current through AutoLISP or certainly Visual LISP, without a call to the command line.

Posted

Lee,

I solved the problem. Calling "LAYER" command and entering its "Filter" option (a hidden option) then entering "Set" option and finally entering the name of desired existing layer filter, you can get the goal. Of course to ensure the command takes effect, you must rename the "layer filter" temporarily, then again return it to its original name, as in the following code:

 


;;;MT:Set:Active:LayerFilter - Mehdad Ahnkhah - Mehre Taban
(defun MT:Set:Active:LayerFilter (%filter-name%)
;; here ensure that %filter-name% exists
(setvar 'Cmdecho 0)
(command
 "_.-LAYER" "_Filter" "_Set" %filter-name% "_eXit" ""
 "_.-LAYER" "_Filter" "_Rename" %filter-name% "temp" "_eXit" ""
 "_.-LAYER" "_Filter" "_Rename" "temp" %filter-name% "_Set" %filter-name% "_eXit" ""
)
(setvar 'Cmdecho 1)
)

Posted
I'm glad you were able to solve it Mehrdad - well done.

Thank you very much Lee.

 

To success:

there are some ways to locate,

if not, there are some ways to create.

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