Jump to content

FILTER Command


Recommended Posts

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • Rooster

    16

  • lpseifert

    8

  • ASMI

    6

  • swazi.71

    3

What I'm trying to do is select all polylines & then explode them through a script. When I run the script it seems to find all the polylines, but only explodes the first one. lpseifert's change still leaves me with the same problem.... ???

Link to comment
Share on other sites

Here's the relevant extract of the script that I've written:

________________________________________________

-LAYER

F

*

LO

*

T

SERVICES_BT,SERVICES_ELECTRIC

U

SERVICES_BT,SERVICES_ELECTRIC

 

FPL

ALL

 

EXPLODE

ALL

________________________________________________

 

And here's the FPL LISP:

________________________________________________

(defun c:fpl(/ cSet)

 

(setq cSet(ssget

'((0 . "LWPOLYLINE"))

); end ssget

); end setq

 

(if cSet

(progn

(princ(strcat "\n" (itoa(sslength cSet)) " found."))

(sssetfirst nil cSet)

); end progn

(princ "\nNothing found. ")

); end if

(princ)

); end of c:fpl

________________________________________________

Link to comment
Share on other sites

The FPL function just reports how many lwpolylines you've selected, that's all. Since the cSet variable is declared as local, the value is lost when the defun c:fpl is closed. Try and make it global and pass it on to the explode command with !cSet.

I didn't test it, and it propably won't work; you may want to consider using lisp to explode the plines instead of a script.

Link to comment
Share on other sites

you may want to consider using lisp to explode the plines instead of a script.

 

OK, sounds good - but I will need help there! As you can see I'm a complete LISP novice!

Link to comment
Share on other sites

Here's a quicky, untested and will probably only work in the current space

(defun c:test (/ ss1)
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE"))))
 (command "explode" ss1 "")
 );defun

Link to comment
Share on other sites

(defun c:test (/ ss1 oldQf)
[color="Blue"](setq oldQf(getvar "QAFLAGS"))
(setvar "QAFLAGS" 1)[/color]
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE"))))
 (command "explode" ss1 "")
[color="#0000ff"](setvar "QAFLAGS" oldQf)[/color]
(princ)
 );defun

 

:)

Link to comment
Share on other sites

QAFLAGS is one of not documentary variables which can accept values from 0 to 32767. The bit 0 (1) influences execution of command Explode. Exact usage of all bits unfortunately is not known. Other way to force AutoCAD to explode all primitive of a selection set - use loop.

Link to comment
Share on other sites

  • 3 weeks later...
(defun c:test (/ ss1 oldQf)
[color="Blue"](setq oldQf(getvar "QAFLAGS"))
(setvar "QAFLAGS" 1)[/color]
(setq ss1 (ssget "x" '((0 . "LWPOLYLINE"))))
 (command "explode" ss1 "")
[color="#0000ff"](setvar "QAFLAGS" oldQf)[/color]
(princ)
 );defun

 

:)

 

I've been using the above written by ASMI (thanks), but I'm finding that it's not exploding everything that I'm expecting it to. If I draw a polyline (using the PL command) and run this, there's no problem. Then there are other polylines in my drawings that don't get exploded. Comparing the properties between the two, the only difference (other than length & position) is that under the MISC section of the properties window the unexploded lines have an FIT/SMOOTH property of none, whereas the ones that did explode didn't have this property at all. I'm sure the LISP above is fine, so does that mean that the lines that are not exploding are not technically polylines or something??

 

EDIT: Ok, looking more closely at my properties, I notice that the lines which are not exploding are classed as '2D Polylines' whereas the ones which are are simply 'Polylines'. So how do I either change 2D PLs into standard PLs, or edit the above LISP to pick them up as well?

Link to comment
Share on other sites

OK - I've done it! For anyone interested, I edited ASMI's LISP from this:

 

(setq ss1 (ssget "x" '((0 . "LWPOLYLINE"))))

 

to this:

 

(setq ss1 (ssget "x" '((0 . "POLYLINE,LWPOLYLINE"))))

 

and hey presto, as they say :)

Link to comment
Share on other sites

  • 2 months later...

Sorry folks - back to this problem again:

 

I'm trying to use a LISP to filter all objects with a z-value of -999, but nothing is being found. Can someone chekc out my code and see if they can spot any problems? Thanks

 

_______________________________

(defun c:fz999(/ cSet)

 

(setq cSet(ssget

'((10 . *, *, -999))

); end ssget

); end setq

 

(if cSet

(progn

(princ(strcat "\n" (itoa(sslength cSet)) " found."))

(sssetfirst nil cSet)

); end progn

(princ "\nNothing found. ")

); end if

(princ)

); end of c:fz999

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