Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selection set problems in vba project?

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
US
I have a vba project that worked great in acad 14 but in acad 2000i it works the first run and teh tells me the named selection set already exists. I have pasted what i believe to be the problem area in the code any ideas?


Private Sub UserForm_Initialize()
Dim BlkG(0) As Integer
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
'declare local variables


Set acad = GetObject(, "AutoCAD.Application")
'set reference to AutoCAD

Set doc = acad.ActiveDocument
'set reference to the drawing

Set ms = doc.ModelSpace
'set reference to model space

Set ssnew = doc.SelectionSets.Add("TBLK")
'create a selection set

Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
Pt2(0) = 3: Pt2(1) = 3: Pt2(2) = 0
'set up the array

BlkG(0) = 2
'group code 2 for block name

TheBlock(0) = "E3load1"
'the name of the attribute block

ssnew.Select 5, Pt1, Pt2, BlkG, TheBlock
'get the block

If ssnew.Count >= 1 Then
'if the block is found

Theatts = ssnew.Item(0).GetAttributes
'get the attributes
 
You will need to check that the selection set is not already in use. Add this before you create the selection set...

'make sure selection set name is not in use

Dim ssDim as AcadSelectionSet
For Each ssDim In ThisDrawing.SelectionSets
If ssDim.Name = "TBLK" Then ssDim.Delete
Next ssDim
 
thanks borgunit. i actually fixed the project by addinf the code ssnew.delete to the button that closes the module. works great but i will use your code example in future projects. thanks you have been a great help. as you can tell i am far from a programmer just someone who needs to learn to make my design go faster
 
Hi,

Does the group 2 code on the filter actually work for the block name (the name you give when you create the block in AutoCAD)?

I've tried several ways to do this this but, the selection set find nothing when I try to filter everything but the block names and the block references..

Maybe I've got the wrong keyword for the block reference: I use

Code:
Dim FiltX(1) As Integer
Dim FiltY(1) As Variant

FiltX(0) = 0: FiltY(0) = "Block"
FiltX(1) = 2: FiltY(1) = "Block1"

When I run portion of the code to get the selection set test it with a:

Code:
MsgBox SS.Count 'Selection set items..

....The count is 0..


Any ideas,

Renegade..
BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top