warshing Posted April 7, 2009 Posted April 7, 2009 Public Sub sele() If Not IsNull(ThisDrawing.SelectionSets.Item("sel")) Then Set sset = ThisDrawing.SelectionSets.Item("sel") sset.Delete End If Set sset = ThisDrawing.SelectionSets.Add("sel") sset.SelectOnScreen End Sub These codes are used by other functions.When run above codes,the application have a error "Can not find key".But run below codes,there is OK Public Sub selsets() Dim sset As AcadSelectionSet Dim str As String Dim selmtxt As AcadMText Dim getobj As AcadEntity If Not IsNull(ThisDrawing.SelectionSets.Item("sel")) Then Set sset = ThisDrawing.SelectionSets.Item("sel") sset.Delete End If Set sset = ThisDrawing.SelectionSets.Add("sel") sset.SelectOnScreen For Each getobj In sset If getobj.ObjectName Like "*Text" Then Set selmtxt = getobj If selmtxt.TextString = "{\C7;0}" Then selmtxt.TextString = "0.01" selmtxt.Update End If End If Next End Sub Quote
CmdrDuh Posted April 7, 2009 Posted April 7, 2009 try Diming the sset inside your version. I think it doesn't know what your trying to do Quote
warshing Posted April 9, 2009 Author Posted April 9, 2009 I have dimed sset by publice dim sset as acadselectionset in the begin of the project,and it's used in other functions.Maybe you are right.I'll try to give sele() a parameter and optimize all sub. Quote
warshing Posted April 9, 2009 Author Posted April 9, 2009 I changed my codes as below Function sele(aa As String) As AcadSelectionSet Dim sset As AcadSelectionSet On Error Resume Next ThisDrawing.SelectionSets(aa).Delete 'Don't know the difference between "ThisDrawing.SelectionSets.Item("sel")" Set sset = ThisDrawing.SelectionSets.Add(aa) sset.SelectOnScreen Set sele = sset End Function Quote
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.