Using Fastsel in LISP

Using Fastsel in LISP

Anonymous
Not applicable
1,851 Views
8 Replies
Message 1 of 9

Using Fastsel in LISP

Anonymous
Not applicable

 Hi

 

I'm trying to write a lisp routine (more of a macro really) which allows me to select a single line, allows to to apply the FASTSEL express tool and then some other functions to the new selection however im unable to get FASTSEL to return anything.

 

I'm still inexperienced with lisp and have tried various combinations of setq and ssget to try to get hold of the new selection but have been unsuccessful for example

 

(setq o (command (fastsel)))

 

simply returns 

 

<Selection set: 5367>

 

on the command line and the routine finishes.

 

I cant for the life of me find any examples of people using FASTSEL in lisp on any forum, could anybody explain the syntax i need to use?

 

Thanks

0 Likes
1,852 Views
8 Replies
Replies (8)
Message 2 of 9

john.uhden
Mentor
Mentor

That's interesting.

(setq o (command anything)) should return nil.

What does just (fastsel) return?  Is it a command or a function?

I can't tell because I'm running only 2002.

 

Others??

John F. Uhden

0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

...

What does just (fastsel) return?  Is it a command or a function?

...


It's an Express Tool.  That means it can't be used in a (command) function.

Kent Cooper, AIA
0 Likes
Message 4 of 9

john.uhden
Mentor
Mentor

Okay. so it's an Express Tool.

But of what kind, a command, a function, or what?

i've gotta believe it can be called if we know what type it is.

 

More importantly, what does it do?

Does the OP really need to use it for his purposes?

If necessary, and really unusable in its current form, aren't we capable of reproducing it in a usable form?

 

Long before Civil 3D, DCA was nothing but a collection of AutoLisp routines.

(Not to diminish the talents of Dave Arnold and his team in NH)

I learned a lot from unencrypting some of them.

John F. Uhden

0 Likes
Message 5 of 9

Anonymous
Not applicable

I was unaware that FASTSEL was an express tool and required special treatment, it seems it must be called using (C:fastsel).

 

After selecting an object I then encountered an error:

 

Exiting Fastsel; error: bad function:

 

Which was solved by adding "(progn " to the start of the routine making it look like:

 

(defun C:lispname()
(progn
(C:fastsel)
;do other stuff here
(princ)
)
)

 

Cheers for the help.

0 Likes
Message 6 of 9

ВeekeeCZ
Consultant
Consultant

Yes, it's a regular lisp stored at c:\Program Files\Autodesk\AutoCAD 2016\Express\fastsel.lsp 

 

So yes, you should call it as any other lisp, (c:fastsel) or (c.fs)

 

You may ensure that lsp is loaded

(if (not c:fastsel) (load "fastsel.lsp"))

 

I don't know about your (progn) solution, does not make a sense to me.

 

 

0 Likes
Message 7 of 9

john.uhden
Mentor
Mentor

If it is a C: function then i doubt you can incorporate it without allowing it to take user input, probably at the very end of your function.  It most likely doesn't take arguments.  Plus, it's return is probably just (princ).

But maybe you can use vlax-add-cmd so it can be used in script format like (command "fastsel" blah blah blah) though each blah will probably be different. :]

 

Once again, what does fastsel do?

Does it really load from a .LSP file or from a .FAS or .VLX?  Maybe you can incorporate its contents into your function, or change it so that it returns something of value.

John F. Uhden

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... 

Once again, what does fastsel do?

....


It can be called by either FASTSEL or the alias FS.  It asks you to select something, and automatically also selects things that touch it [meet it at its ends, cross it, etc.].  There's a FSMODE command that acts like a System Variable setting -- if it's OFF, FS "finds" what you pick and whatever is touching that object directly; if it's ON, it "finds" what you pick and whatever touches that, and whatever touches those things -- as many things as are touching each other in "chain" fashion.

 

It does require you to pick something after calling it -- I tried calling it with something pre-selected, both in the ordinary manual way and with something selected/highlighted/gripped in (sssetfirst) fashion, and neither way worked.  I tried using it via (C:FS) in AutoLisp, and it did invoke it, but it seemed to take over at the point where it was called, and anything after it in the code was lost.  So I'm not sure it can be used internally as a selection method for something that wants to then do anything with what it finds.

Kent Cooper, AIA
0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor

That's really interesting, but I don't think I want to select every object that touches a polyline contour (building, walk, curb, text, leader, drain. sewer, water main, property line, setback, easement, etc.)

 

I guess I still recommend modifying the source to return a selection set, if that's what is desired.

John F. Uhden

0 Likes