Jump to content

Recommended Posts

Posted

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

Posted

try Diming the sset inside your version. I think it doesn't know what your trying to do

Posted

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.

Posted

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

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