VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selection Set Filter

74 REPLIES 74
Reply
Message 1 of 75
pellacad
1029 Views, 74 Replies

Selection Set Filter

I am trying to collect all the dimensions in my -refedit session...

My code follows...

---snip---

Dim ssetObj As AcadSelectionSet

ssetObj = objAcad.SelectionSets.Add("SS1")

ssetObj.Select(AcSelect.acSelectionSetA ll, , , "0", "DIMROTATED")

Dim S1 As AcadDimRotated

For Each S1 In ssetObj
MsgBox(S1)
Next S1

---snip---

It seems pretty simple...can anyone see what's going wrong or maybe have a better way?

All cards and letters appreciated!


I solved my earlier REFEDIT open and closing issues by using the following code (in case anyone can use it)...

objAcad.ActiveDocument.SendCommand("(setq EN1 (entlast)) ")

objAcad.ActiveDocument.SendCommand("(command ""-refedit"" & ""(cadr EN1)"" & vbCr & ""ok"" & vbCr & ""a"" & vbCr & vbCr) ")

DimStyleAdjust() '<-- THIS IS THE SUB WHERE I NEED TO PUT MY DIMENSION SELECTION SET STUFF

objAcad.ActiveDocument.SendCommand("(command ""refclose"" ""S"") ")


ROCK ON...TALK 'ATCHA LATER...keep those cards and letters coming!
74 REPLIES 74
Message 61 of 75
Anonymous
in reply to: pellacad

don't bother wasting any more of your time on Tony [and his protege paul].
Just agree that he is right [even though nothing could be further from the
truth] and move on.

he has a long history of going off into these childish triades and never
offers any reasonable justification for it [a simple search will prove this
out]. he has it in his mind that whenever he says something that no should
dare defy him.

he then attempts to turn it on you in an attempt to save his reputation
[which is tainted at best]. he thinks i have a reputation that he can touch
but as is usual, he's wrong. but he stills makes his attempts.

i don't doubt that he has some programming ability but he has a strange way
of showing it. he reminds me of someone in a king novel [better left alone].


wrote in message news:5908082@discussion.autodesk.com...
but children are our most valuble resource...
Message 62 of 75
Anonymous
in reply to: pellacad

Alright so it a bit old but still very cool...~) As soon MS starts writing its core products on something else - I give up on it.

Don't let anyone dissuade you from ARX - get in and start digging it actually fun... They are actually very helpful in the ARX group but won't coddle you so you need to do you homework.
Message 63 of 75
NathTay
in reply to: pellacad

Pot calling the kettle black.
Message 64 of 75
NathTay
in reply to: pellacad

That is because you are stupid and why people are well advised not to blindly accept your help.

If a user uses multiple programs written by shoddy programmers that each uses multiple selection sets they can quite easily reach the limit.

Please explain why a blanket use of On Error Resume Next is acceptable.
Message 65 of 75
Anonymous
in reply to: pellacad

>>>>> The reason you should delete selection sets after using
>>>>> them is because there is a limit to how many can exist.

"Steve" wrote

>> please, i can't think of a single instance, where this could ever be an
>> issue in a vba macro. nice try though.

But that wasn't your mistake.

Your mistake (which is a typical 'beginner' mistake) was this:

>> On Error Resume Next

Without following it with this:

On Error Goto 0

So, with your code as written, *any* error of any kind that occurs anywhere in the remainder of the sub, will be hidden.

So, the OP should thank you... He should thank you for providing an excellent example of shoddy, rank amateur junk code, because that along with the above, will allow him and others to learn how to not create the same kind of garbage.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Message 66 of 75
cadger
in reply to: pellacad

i'm sorry that acadx didn't work out the way you wanted it to 😞 it must have been disheartening when you finally realized you wouldn't be able to get it to work with newer versions. but i'm sure you'll come up with another baby some day (acadxtabs looks interesting, but not nearly as challenging for you as acadx).
Message 67 of 75
Anonymous
in reply to: pellacad

wrote:

>> i'm sorry that acadx didn't work out the way you wanted it to 😞 it must have been disheartening when you finally realized you wouldn't be able to get it to work with newer versions. <<

What are you talking about?

It took a couple days to get it working on R17, and works on every release of AutoCAD.

But, because I've long since abandoned the ActiveX sandbox that you're stuck in, I no longer need AcadX, because now I can just about everything AcadX did using the AutoCAD .NET API.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Message 68 of 75
pellacad
in reply to: pellacad

Good morning Tony,

(OK...I'm sitting here trying to think of how/what to write so I'll do this correctly...)

I have been looking for 3 days now (it seems like forever)...

You mention in your post below that you've been successful in "just about everything AcadX did using the AutoCAD .NET API"...I need some direction please...

I seem to be having trouble using the RemoveItems method with my selection sets.

Here's my code...

Dim intI As Integer
Dim objEnts() As AcadEntity
ReDim objEnts(oSS3.Count - 1)
intI = 0
If oSS3.Count > 0 Then
For Each oEntity In oSS3
If TypeOf oEntity Is AcadDimRotated Then
MsgBox("We have an AcadRotDimension...intI = " & intI)
objEnts(intI) = oEntity
intI = intI + 1
End If
Next oEntity
End If
MsgBox("Ready to remove objects.") ' <- THIS EXECUTES

oSS3.RemoveItems(objEnts) ' <- THIS FAILS

Any help appreciated! Thanks!
Message 69 of 75
Anonymous
in reply to: pellacad

The basic problem(s) you're having is that you are trying to
do AutoCAD programming without first having to learned the
basics of programming. Like for example, how to work with
arrays. It doesn't matter what langauge you're using because
the most basic concepts that you're missing are not language-
specific, they just vary slighly in how they work.

Instead of Dim objEnts() As AcadEntity, use a List Of(AcadEntity)
(look up the List Of() class in the docs). To use that class you
must use 'Imports System.Collections.Generic' if you don't already
have it.

The List Of() class allows you to construct a list of objects by
adding one at a time, without having 'empty' or null elements,
which is why it isn't accepting what you give it. You don't have
to give it the size when you create it, just call the Add() method
each time you add another element. Look for examples of using
it, don't ask me to show you how.

After you create the list of the objects, you can use the ToArray()
method to convert them to an array that you can pass to the
RemoveObjects() method.

In the mean time, unless someone here wants to tutor you on
programming 101, I strongly suggest you stop trying to run,
and spend some time learning to crawl and walk first.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com

wrote in message news:5911373@discussion.autodesk.com...
Good morning Tony,

(OK...I'm sitting here trying to think of how/what to write so I'll do this correctly...)

I have been looking for 3 days now (it seems like forever)...

You mention in your post below that you've been successful in "just about everything AcadX did using the AutoCAD .NET API"...I need some direction please...

I seem to be having trouble using the RemoveItems method with my selection sets.

Here's my code...

Dim intI As Integer
Dim objEnts() As AcadEntity
ReDim objEnts(oSS3.Count - 1)
intI = 0
If oSS3.Count > 0 Then
For Each oEntity In oSS3
If TypeOf oEntity Is AcadDimRotated Then
MsgBox("We have an AcadRotDimension...intI = " & intI)
objEnts(intI) = oEntity
intI = intI + 1
End If
Next oEntity
End If
MsgBox("Ready to remove objects.") ' <- THIS EXECUTES

oSS3.RemoveItems(objEnts) ' <- THIS FAILS

Any help appreciated! Thanks!
Message 70 of 75
pellacad
in reply to: pellacad

Hi Tony, thanks for the prompt reply...

The example I show is the result of several searches for info about the RemoveItems method...

The use of the array for the dimension selection set was shown by at least two different posters, if not three or four.

I've been trying to sort this out since last Wednesday (so I've got 3 or 4 days of work on this so far)...

(I should have known this might become tricky when Jerry Winters didn't show anything regarding the use of RemoveItems or AddItems in his latest book.) DRAT!!!

At any rate, you message to me instructing me not to ask you for further help has been received and will be reluctantly honored.

Using your suggestion regarding "List Of" and my own limited skills I have developed to date, I have, in an effort to uncover (or perhaps, discover is a better word) taken the following steps in order to find a solution to my dilemma...

1. Google search..."VB.NET AutoCAD List Of"...produced no descernable results
2. AutoCAD Help / Developer Help search..."List Of"...again, produced no results of any consequence
3. MS VS VB.NET 2005 Object Browser search (Imports System.Collections.Generic has been put into place with my other Imports statements)..."List Of"..."Search found no results"
4. I then began trying to put "List Of (objEnts)" into my program...Nothing Good Happened
5. Tried "Dim objEnts list of AcadEntity"...same results...nothing good.

So without an example of how to use this code, it appears I am once again floating on a vast ocean of knowledge...with no rudder, and only my own hot air to fill the sails.

Have a good day!

In closing, is there anyone out there who could show me how to remove a selection set of dimensions from the entities comprising a block?

dot dot dot...dash dash dash...dot dot dot
Message 71 of 75
Anonymous
in reply to: pellacad

>> At any rate, you message to me instructing me not to ask you for further help has been received and will be reluctantly honored. <<

You're free to ask for help, and will get help from me, *after* you make a personal investment in learning to use the tools that you're trying to use, and at this point, it's clear that you haven't done that.

It also looks like you're having difficulty finding things yourself, even when you get reasonable hints on where to look and what to look for.

Visual Studio Documentation, Index Tab:

List(Of T) class

The full name of the class is 'System.Collections.Generic.List'


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com

wrote in message news:5911833@discussion.autodesk.com...
Hi Tony, thanks for the prompt reply...

The example I show is the result of several searches for info about the RemoveItems method...

The use of the array for the dimension selection set was shown by at least two different posters, if not three or four.

I've been trying to sort this out since last Wednesday (so I've got 3 or 4 days of work on this so far)...

(I should have known this might become tricky when Jerry Winters didn't show anything regarding the use of RemoveItems or AddItems in his latest book.) DRAT!!!

At any rate, you message to me instructing me not to ask you for further help has been received and will be reluctantly honored.

Using your suggestion regarding "List Of" and my own limited skills I have developed to date, I have, in an effort to uncover (or perhaps, discover is a better word) taken the following steps in order to find a solution to my dilemma...

1. Google search..."VB.NET AutoCAD List Of"...produced no descernable results
2. AutoCAD Help / Developer Help search..."List Of"...again, produced no results of any consequence
3. MS VS VB.NET 2005 Object Browser search (Imports System.Collections.Generic has been put into place with my other Imports statements)..."List Of"..."Search found no results"
4. I then began trying to put "List Of (objEnts)" into my program...Nothing Good Happened
5. Tried "Dim objEnts list of AcadEntity"...same results...nothing good.

So without an example of how to use this code, it appears I am once again floating on a vast ocean of knowledge...with no rudder, and only my own hot air to fill the sails.

Have a good day!

In closing, is there anyone out there who could show me how to remove a selection set of dimensions from the entities comprising a block?

dot dot dot...dash dash dash...dot dot dot
Message 72 of 75
pellacad
in reply to: pellacad

In the end...I stuck with the array that I was trying to use.

With the inclusion of the "ReDim Preserve objEnts(intI)
" method located inside my loop, I was able to index my array as it found each new AcadDimRotated...

It worked nicely thereafter...and I was on to my ultimate goal...removing a selection set from a selection set.

After my array was built correctly, I used "oSS3.RemoveItems(objEnts)" and the task was performed.

I'm sorry you found interacting with me to be so irksome.

You made a lot of comments about my programming efforts that were both unfair and untrue. Your comments on this and other threads (regarding my questions) seemed unnecessarily stern, harsh and hurtful.

In the end, I offer my thanks to every forum user who responded in an effort to help me, for taking the time to share their knowledge and expertise. I really don't know how I could perform my job without this valuable resource.

Have a good weekend all, see you in the forums!
Message 73 of 75
Anonymous
in reply to: pellacad

>>I really don't know how I could perform my job without this valuable resource.
By taking Tony's advice constructively instead of personally. If you had gone to each
of your many theads on this basic question (spanning two groups) and pointed them
to Norman's answer you'd be ok... But you decide to take one last opportunity to
complain about the best advice you were given...

Remember this thread started with you just trying to create a filter however you wanted to
instead to looking at the many samples availible... You can kid yourself about the homework
you've done but don't insult us!

Those who don't read are no better off than those who refuse to... The latter just
a have a good excuse!

wrote in message news:5915823@discussion.autodesk.com...
In the end...I stuck with the array that I was trying to use.

With the inclusion of the "ReDim Preserve objEnts(intI)
" method located inside my loop, I was able to index my array as it found each new AcadDimRotated...

It worked nicely thereafter...and I was on to my ultimate goal...removing a selection set from a selection set.

After my array was built correctly, I used "oSS3.RemoveItems(objEnts)" and the task was performed.

I'm sorry you found interacting with me to be so irksome.

You made a lot of comments about my programming efforts that were both unfair and untrue. Your comments on this and other threads
(regarding my questions) seemed unnecessarily stern, harsh and hurtful.

In the end, I offer my thanks to every forum user who responded in an effort to help me, for taking the time to share their
knowledge and expertise. I really don't know how I could perform my job without this valuable resource.

Have a good weekend all, see you in the forums!
Message 74 of 75
pellacad
in reply to: pellacad

Have a good day Paul...thank you for your valued comments!
Message 75 of 75
Anonymous
in reply to: pellacad

>>Have a good day Paul...thank you for your valued comments!

You're welcome... Tony gave me the same advice he gave many years ago and although it might of stung a bit at first - it was the best advice I could have been given... Good luck!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost