Jump to content

Impossible to run program using SelectionSets


Karma

Recommended Posts

Hi,

I have a good experience in AutoCAD but no skills in programming, I just started with Acad VBA (Sorry my English is basic as well).

I started by some simples programs, as creating drawing geometries...

Now, I would like to know how build a code for selecting objects in the drawing. I tested this program (see below) and many others to understand the logical; I had every time an error on the same line (in red).

I learned that this line is for attributing a new dimension to ssetObj object. but,

What is the problem? Could someone help me?

Thanks ;)

[color=#303030][font=Tahoma]Private Sub CommandButton3_Click()[/font][/color]
[color=#303030][font=Tahoma]Dim ssetobj As AcadSelectionSet[/font][/color]
[color=#303030][font=Tahoma]'On Error Resume Next[/font][/color]
[font=Tahoma][color=red]Set ssetobj = ThisDrawing.SelectionSets.Add("SS01")[/color][/font]
[color=#303030][font=Tahoma]frmForm1.Hide[/font][/color]
[color=#303030][font=Tahoma]ssetobj.SelectOnScreen[/font][/color]
[color=#303030][font=Tahoma]ssetobj.Erase[/font][/color]
[color=#303030][font=Tahoma]frmForm1.Show[/font][/color]
[color=#303030][font=Tahoma]End Sub[/font][/color]
[font=Tahoma][color=#303030]

[/color][/font]

Edited by Karma
Link to comment
Share on other sites

A quick answer

 

to find blocks = INSERT

FilterDXFCode(0) = 0
FilterDXFVal(0) = "INSERT"

Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

a bit more

BLOCK_NAME = "SCHEDTEXT"

For Cntr = 0 To SS.Count - 1
If SS.Item(Cntr).Name = BLOCK_NAME Then
  attribs = SS.Item(Cntr).GetAttributes

Link to comment
Share on other sites

I found that, I must delete the selection set "SS01" before running a second time the routine. Otherwise, the program tries to re-create the same selection SS01.

Thanks Bigal

Then:

[font=Tahoma]Private Sub CommandButton3_Click()[/font]
[font=Tahoma][color=black]Dim ssetobj As AcadSelectionSet[/color][/font]
[font=Tahoma][color=black]Set ssetobj = ThisDrawing.SelectionSets.Add("SS01")[/color][/font]
[font=Tahoma][color=#303030]frmForm1.Hide[/color][/font]
[font=Tahoma][color=#303030]ssetobj.SelectOnScreen[/color][/font]
[font=Tahoma][color=#303030]ssetobj.Erase[/color][/font]
[b][color=#303030][font=Tahoma]ssetobj.Delete[/font][/color][/b]
[color=#303030][font=Tahoma]frmForm1.Show[/font][/color]
[font=Tahoma][color=#303030]End Sub[/color][/font]
Link to comment
Share on other sites

Your code may be like this

 

[font=Tahoma]Private Sub CommandButton3_Click()
   Dim sset As AcadSelectionSet
   Me.Hide
   Set sset = ThisDrawing.SelectionSets.Add("GetAttributes")
   sset.SelectOnScreen
   CommandButton3.Caption = sset.Count
   Me.Show
End Sub

[/font]

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