Author Topic: Using a Selection Set once in ACAD?  (Read 10600 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #15 on: December 21, 2007, 02:29:56 PM »

Hi Jeff

Thank you again!
That was a very good explanation.

This whole thing started as a result of the email notifications not working for a day or so, if you recall?
I did not see many of those posts until after I had already sifted through that cumbersome VLAX Module and took what I needed.

I did see your post about accessing Excel and you are right, I thought it was a great idea in theory and was ready to post and tell you so; then I saw that Glenn said it would be a scary thing to do. I also realized that what you said in your aforementioned comment; that it does not really make sense to connect to Excel, just to do that. Would it be harmful; I'm not so sure.

I've seen a VB Script, that you double click on it and it closes all programs in one shot.
It is a useful little utility, however, the person that developed it said, you must have Word installed.
At first, I was like WTF? I must admit, I have used it a few times and there has been no problem.

Actually, here is the other unique situation I am facing; that I never felt that I needed to explain.
My boss is a fantastic AutoLisp programmer, he has done some great things.
He is a pretty good VBA programmer; he picks up on it very quickly as he has been programming for years.
For the last 4 or so years, I have been in trenched in VBA; help screens, examples, forums etc.
I am not saying by any stretch that I am a better programmer then anyone but I happen to understand and know my way around the syntax and environment a bit more then he does, I'm sure.

OK, so of course he still does a lot in LISP because he is really fast at it and LISP is still alive and well; so if VBA is not explicitly needed, then LISP is fine. Well, there are things that he has done in LISP that frankly may not be worth out time to try to re create in VBA, so I simply said, OK, if we need to expand on it via VBA, then maybe we can do something. That is what started this whole VLAX ordeal LOL

OK, finally, to your question :)
I created an sset in VBA and did not delete it at the end because I (or the user) may want to use it for further things in ACAD, as they are not programmers. So, I thought that it would be nice to keep it available for this sort of thing.
May be I could use Filter in ACAD, I don't know?
I'm not sure how The Filter command in ACAD would grab the last created object.
If it could, then I could use that named sset in ACAD.
I was trying to reuse the (named) selection set in ACAD to do somethings yesterday and just got frustrated because I could not access it by name; which really amazes me.

May be there is a way; if so, please let me know.
Otherwise, your routine is excellent!

Thank you,
Mark

sinc

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #16 on: December 21, 2007, 03:07:17 PM »
In general, it is considered bad practice to create selection sets that hang around.

The system is limited to a rather small (255?) number of them, so if you create selection sets without destroying them, you may lock up Autocad and force your user to shut it down and restart.

And even if you do not create enough selection sets to hit the limit, imagine if other programmers also created "just a few" selection sets and left them hanging around...  Eventually, Autocad might grind to a halt, and it would be difficult to figure out why...

A better choice is to use an Extension Dictionary, or the Named Object Dictionary, or an external file, or something along those lines.

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Using a Selection Set once in ACAD?
« Reply #17 on: December 21, 2007, 03:11:22 PM »
OK, we now know the reasoning behing the madness :-)

And this is precisely why I asked, it pretty much follows what I ran into. Sometimes it does make sense to bend/break the rules, SO LONG AS we don't get in the habit of doing so.

[speculation]
You must remember that SS's were around long before ActiveX. Then (and now, in the lisp/ename world) they were known as <Selectionset: d4ca>. IOW, they were sequentially named in HEX.  When ActiveX came around, the programmers thought "Wouldn't it be cool to have SS's with names we can pronounce?" And so it was done. The problem is, there was no way to introduce that back to the old SS method/naming without breaking every routine/function/program written using the old method. So we must live with the 2 different & incompatable versions.
[/specultion]

So....... No, I know of no other way to get the ActiveX SS into a command-usable SS.

For future questions, it may be a good idea to put in the initial posting, what is the purpose and the reasoning behind the question. That way if it's a convoluted thing you are attempting to achieve, everyone will know that this may require a different train of thought. The initial post here was close, but a few more sentences describing it (as you just did) may have staved off some comments.

And yeah, what Sinc said whilst I was typing this......I hadn't even thought of that aspect yet.

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #18 on: December 21, 2007, 04:05:04 PM »

Yes, that is good to know; thank you for the explanation.
Interestingly enough, ACAD allows you (the user) to create named filters, named layer filters etc.
So, I would imagine that there is limits on it all; therefore ACAD should allow us to access named ssets; that's why prior to me doing VBA, they were like a great mystery to me. Now, I can create them in VBA but I can't use them in CAD? It is still a bit bizarre Jeff, don't you think?

That is great that Sinc filled us in on that.
I realize that it is is good practice to delete ssets when we are done in VBA but this is a rare case where I would like to keep it alive.
Again, the weird thing is, no one knows it is alive because there is no name still in ACAD LOL
Hummm, also, is this limitation limited to a drawing? If so, I could not see a need for too many ssets in one drawing.

I understand what you are saying Jeff about giving more info upfront. On the same token; if I don't understand the posters intents, then I simply ask him/her for my info or I just leave it alone. I use to get told that my posts (questions) were too long and too convoluted, so I really do my best now to try to keep it short and concise. :)

I know it seems like I ask some far out things sometimes but "please" understand, it is out of necessity.
We did a project here; that ended up having like 120 or so controls in all of the forms.
Then my boss decided (for a very good reason) that we needed to rename them all.

So, in one of my posts, I asked if we can loop through all controls in a project and globally rename them.
While that may sound like a weird request, guess what, it works :)
I can use wild cards and all.
Once the control (obj) is renamed, then the sub name is renamed (dynamically) respectfully.
So, it was a definite good tool to have as we will likely run into that again.

So, back to Sinc's post;
I am not sure how to use
Extension Dictionary, or the Named Object Dictionary, or an external file to acheive this. :(

Thanks!

Mark


ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #19 on: December 21, 2007, 04:28:35 PM »

Jeff, is there any way that the code could be modified slightly so that the user only needs to type in the sset name after the routine is loaded?

Thanks

Mark

sinc

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #20 on: December 21, 2007, 05:03:38 PM »
Another thought occurred to me...

That limit on selection sets is actually 128, but it's possible that the limitation is due to the way Autolisp is implemented, and the limitation only exists if you are using Lisp...  Someone else may know the details of it.  But it's possible that the selection-set limit may not affect you in VBA.

Here's the relative quote I found in the developer help, which seems to indicate it is only an Autolisp issue:

Quote
Selection sets consume AutoCAD temporary file slots, so AutoLISP is not permitted to have more than 128 open at one time. If this limit is reached, AutoCAD cannot create any more selection sets and returns nil to all ssget calls. To close an unnecessary selection set variable, set it to nil.

Can you get to the NOD in VBA?  I've been using .NET lately, so I've gotten used to having the NOD there, but I never used it before I started doing .NET programming.

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #21 on: December 21, 2007, 05:07:49 PM »

Hey Sinc,

That is interesting and it makes sense.
I think AutoLISP Selection Sets are created right in ACAD whereas it doesn't look like VBA tosses them off to the App. So, this could very well be true and perhaps why it was developed not to.

So, are you telling me that I can still access the Sset via Named Object Dictionary in VBA?

Thank you,
Mark


Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Using a Selection Set once in ACAD?
« Reply #22 on: December 21, 2007, 05:21:29 PM »
Just ran a quick test....I could only create 124 SS's in VBA before it errors out.

Jeff, is there any way that the code could be modified slightly so that the user only needs to type in the sset name after the routine is loaded?
Not off the top of my head.....how would you distinguish the SS name vs a command or alias?

sinc

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #23 on: December 21, 2007, 05:30:31 PM »
The NOD is something else, and has nothing to do with selection sets.

It's basically just a dictionary that you can stuff things into.  That includes other dictionaries.  So, your app could create a dictionary in the NOD, then store application-specific stuff inside it.  The NOD is stored in the drawing database, so this is one way of storing any sort of generic data inside an Autocad drawing in a way that you can get to it later, even if Autocad is shut down and restarted.  And each drawing has its own NOD, so its drawing-specific.

I *think* you can get to the NOD in VBA.  In .NET, the Database has a method for getting the NamedObjectDictionarID, then you can just retrieve it using a transaction.  But to tell you the truth, I've gotten so far into .NET that I have a hard time remembering what things are like in VBA and Lisp.  Since I switched, I've found very little reason to look back.

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #24 on: December 21, 2007, 05:33:19 PM »
WOW!

Why would someone need to create so many Ssets? I guess I should never say never.
We could always clear and re use Ssets as well if necessary as opposed to just deleting them.

I have never used more then one per Sub, but that is me, I am sure the need to do more will come up in the future, but 128, WOW!

As fas as The VLISP routine, I am not a LISP Programmer unfortunately, however, I would like to have something like:

Totally Pseudo here:
(getvbss  & "Please Enter Ssetname", (Ssetname))

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #25 on: December 21, 2007, 05:36:57 PM »

Sinc,
I will need to look into that, thank you!


ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #26 on: December 21, 2007, 06:17:09 PM »

Jeff

Another one of my weird ideas but it can absolutely be done.
Using The FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")

We can use the WriteLine Method and simply place the name of the Selection Set into The LISP routine.

If you tell me where the name needs to go and on what line in The LISP routine, I can probably get The Sub to write the line in. That would be pretty cool and dynamic

Mark

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #27 on: December 21, 2007, 06:19:12 PM »

That way, once we run the VLISP routine; the selection set name will already be in there; then accessible in CAD

Yeah, that would be cool


Mark

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #28 on: December 24, 2007, 02:02:46 PM »

Jeff

I wrote this little sub in VBA that (I think) will work well with the GetVbSS.lsp routine
Right after the lisp routine is ran, we could run this sub; then the user only has to type in The Selection Set name into the inputbox.

This was what I was getting at with The LISP routine.
I just wanted to have the type the name; only I don't know enough LISP to even make that happen.

Mark

Code: [Select]

Sub GetVbSS()
 
Dim Ssetname As String
 
Ssetname = InputBox("Type Selection Set name")
 
ThisDrawing.SendCommand "(GetVbSS " & Chr(34) & (Ssetname) & Chr(34) & ")" & vbCr
 
End Sub

ML

  • Guest
Re: Using a Selection Set once in ACAD?
« Reply #29 on: January 11, 2008, 02:13:52 PM »

Jeff,
I scrapped the above idea; that wasn't very good, it threw me out of my command; however, I am still very interested in this topic, I have just been really busy lately

I did find that if I load the LISP routine prior to The VBA routine.
Then, you have a separate button or pull down (whatever) with something like (ss "Img") only in it, then I can retrieve the named Sset transparently; I thought that was great!

So, I was in the copy command; prompted to select objects, I clicked the button with (ss "Img") in it and sure enough, it worked. That is super!

Still, I do want to re visit this again

Mark