Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

VB.NET Selection Set Convert VBA to .NET

$
0
0

So, I have looked online but with no success found the correct way to convert the below code from VBA to VB.NET. I have tried using PromptSelection to get the selection set but i get an error each time, so i must be doing something wrong to convert this code. can someone help me with this?

 

Sub redoScale()

'---set scale to the scale of last block
'---this is for the case when a drawing is reopened and the
'---scale is different than the default of 1

Dim ent As Object
Dim EntGrp(0) As Integer
Dim EntPrp(0) As Variant
Dim ssNew As Object
Dim fuseAtts As Variant
Dim entlast As AcadEntity

'---if TBLK not yet defined, error occurs when trying to delete it
On Error GoTo errHandle

If ThisDrawing.SelectionSets.count > 0 Then

'---delete previous instance of TBLK selection set
ThisDrawing.SelectionSets("TBLK").Delete
End If

Set ssNew = ThisDrawing.SelectionSets.Add("TBLK")

'Filter for Group code 2, the block name
EntGrp(0) = 2

'The name of the block to filter for
EntPrp(0) = "device?,fuse?"

'find the block
ssNew.Select acSelectionSetAll, , , EntGrp, EntPrp

If ssNew.count = 0 Then
'---no fuses found
dScale = 1
pScale = 0.0002
Else
'---set scale to that of last block drawn
findLastInsert
End If
scaleCheck = True

Exit Sub

errHandle:
MsgBox Err.Description & vbCrLf & "Error Number: " & Err.Number
Resume Next
End Sub


Viewing all articles
Browse latest Browse all 14319

Trending Articles