Selection Sets working in VB

Selection Sets working in VB

Anonymous
Not applicable
213 Views
3 Replies
Message 1 of 4

Selection Sets working in VB

Anonymous
Not applicable
I don´t know if this is a normal situation:
I have a macro running in VBA that builds a collection of referenced blocks
in a drawing from a selection set. The key of each member in the collection
is the value of one attribute. Later, it uses this collection to rapidly
locate the block in the drawing, based in the value of the attribute. The
macro runs very fast with about 1000 blocks.
But, for other reasons, I have to have this macro running in VB 6. It works,
but very very slow. Is this normal?. Anyone can advise me in other way to
obtain the same result?

Luis León
Caracas, Venezuela
0 Likes
214 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
VB applications linked to Acad are always a little slower than VBA applications. It's hard to tell what might speed up/slow down your application as long as I haven't seen your code. Can you place it on the net? I've had the same problem once. What helped me out then was late-binding....

Regards,
Joeri Tuyn
0 Likes
Message 3 of 4

Anonymous
Not applicable
Put your procedure in an ActiveX DLL, compile it, register it, set a reference to the new DLL and just call it from the VBA host environment.

Joe
--
0 Likes
Message 4 of 4

Anonymous
Not applicable
This is the sub tha cuases the problem in VB
6:

 

Private Sub BuildCodCol()
    Dim
ssBlk As AcadSelectionSet
    Dim objBlk As
AcadBlockReference
    Dim Attlist As
Variant
    Dim iCod(1) As Integer
    Dim
vCod(1) As Variant
    Dim CodCat As
String
    Dim index As Integer
    Dim i As
Integer
   
   
    On
Error Resume Next
    Set ssBlk =
ThisDrawing.SelectionSets.Add("CodBlk")
    If Err
Then
       
ThisDrawing.SelectionSets("CodBlk").Delete
       
Set ssBlk =
ThisDrawing.SelectionSets.Add("CodBlk")
       
Err.Clear
    End If
   

    iCod(0) = 0: vCod(0) = "INSERT"
   
iCod(1) = 2: vCod(1) = "CAT-CPA"
   
   
ssBlk.Select acSelectionSetAll, , , iCod, vCod
   

    If ssBlk.Count = 0
Then
        MsgBox "No hay bloques",
vbExclamation
       
ThisDrawing.SelectionSets("CodBlk").Delete
       
Set ssBlk = Nothing
        Exit
Sub
    End If
   
   
index = 0
   
    For Each objBlk In
ssBlk
        Attlist =
objBlk.GetAttributes
        For i = 0 To
UBound(Attlist)
           
If Attlist(i).TagString = "CATFICHAIDCAD"
Then
               
CodCat =
Attlist(i).TextString
               
Exit For
           
End If
       
Next
       

        ColCod.Add objBlk,
CodCat
        If Err
Then
           
Err.Clear
           
objBlk.layer =
"Repetido"
           
If Err
Then
               
Err.Clear
               
Dim objLay As
AcadLayer
               
Set objLay =
ThisDrawing.Layers.Add("TMPDuplicado")
               
objLay.Color =
acCyan
               
objBlk.layer =
"TMPDuplicado"
           
End If
        End
If
    Next
   
   
ThisDrawing.SelectionSets("CodBlk").Delete
    Set ssBlk =
Nothing
   
End Sub

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
VB
applications linked to Acad are always a little slower than VBA applications.
It's hard to tell what might speed up/slow down your application as long as I
haven't seen your code. Can you place it on the net? I've had the same problem
once. What helped me out then was late-binding....

Regards,
Joeri Tuyn

0 Likes