Karma Posted February 5, 2013 Share Posted February 5, 2013 (edited) 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 February 6, 2013 by Karma Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 6, 2013 Share Posted February 6, 2013 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 Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 6, 2013 Share Posted February 6, 2013 Please read the CODE POSTING GUIDELINES and edit your code to include Code Tags. Quote Link to comment Share on other sites More sharing options...
Karma Posted February 6, 2013 Author Share Posted February 6, 2013 @ SLW210, you are the best! Quote Link to comment Share on other sites More sharing options...
Karma Posted February 6, 2013 Author Share Posted February 6, 2013 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] Quote Link to comment Share on other sites More sharing options...
Rajparamasivam Posted February 7, 2013 Share Posted February 7, 2013 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] Quote Link to comment Share on other sites More sharing options...
Karma Posted February 8, 2013 Author Share Posted February 8, 2013 Thanks Rajparamasivam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.