Re: DVB file

#16
Hi Steven,

Please refer to the official document and modify it to fix with the IntelliCAD.
Select method.png
Select method.png (130.03 KiB) Viewed 10187 times
Here's the modified function SSetCreate base on your one.

Code: Select all

Function SSetCreate(d_SetName As String, d_Mode As Integer, d_Data As String) As SelectionSet
    Dim t_SSET As SelectionSet
    Dim t_Point1 As Point
    Dim t_Point2 As Point
    Dim t_Code1 As Variant
    Dim t_Value1 As Variant

    Set t_Point1 = Library.CreatePoint(0, 0)
    Set t_Point2 = Library.CreatePoint(300, 200)
    
    t_Code1 = d_Mode
    t_Value1 = d_Data
    
    Set t_SSET = ActiveDocument.SelectionSets.Add(d_SetName)
    'ActiveDocument.SendCommand ("zoom all" + vbCr)
    t_SSET.Select vicSelectionSetAll, t_Point1, t_Point2, t_Code1, t_Value1 
    'ActiveDocument.SendCommand ("zoom p" + vbCr)
    Set SSetCreate = t_SSET
End Function

Re: DVB file

#18
Could we (you :) ) have used vicSelectionSetInsideWindow as an alternative to vicSelectionSetAll ?
and if yes, how would that impact the code?

I believe that the code is looking for the block "DAPDRB00" within the window contained within the points 1 & 2

SteveN

Re: DVB file

#19
Hi Steven,

First, the above only is converting your AutoCAD code to work on IntelliCAD.
Yes, in case you want to select the block named "DAPDRB00" within a rectangle defined by two point corners, you should use the parameter vicSelectionSetInsideWindow instead.

Code: Select all

t_SSET.Select vicSelectionSetInsideWindow, t_Point1, t_Point2, t_Code1, t_Value1 
Regards,

Re: DVB file

#20
Thanks again Quan.

MY understanding of this section of code is looking for a block (dxf code 2) that is named DAPDRB00 inside the window (0,0 to 300,200).
If it does then it loads the form DAP_DPP.

Code: Select all

    If (t_SSET.Count = 1) Then
        Set t_Form = DAP_DPP
         t_Form.Show
        End If
What is actually happening when i select the macro :
If the drawing is empty the form does not display, and a zoom all is executed. as expected.
However if ANY entity is in the drawing in any location the form is loaded??

Here is what I have

Code: Select all

Function SSetCreate(d_SetName As String, d_Mode As Integer, d_Data As String) As SelectionSet
    Dim t_SSET As SelectionSet
'--------original-------
'    Dim t_Point1(0 To 2) As Double
'    Dim t_Point2(0 To 2) As Double
'    Dim t_Code1(0) As Integer
'    Dim t_Value1(0) As Variant
'    Dim t_Code2 As Variant
'    Dim t_Value2 As Variant

'    t_Point1(0) = 0: t_Point1(1) = 0: t_Point1(2) = 0
'    t_Point2(0) = 300: t_Point2(1) = 200: t_Point2(2) = 0

'    t_Code1(0) = d_Mode
'    t_Value1(0) = d_Data
'    t_Code2 = t_Code1
'    t_Value2 = t_Value1
'--------original-------

'--------QUAN-------
    Dim t_Point1 As Point
    Dim t_Point2 As Point
    Dim t_Code1 As Variant
    Dim t_Value1 As Variant

    Set t_Point1 = Library.CreatePoint(0, 0)
    Set t_Point2 = Library.CreatePoint(300, 200)
    
    t_Code1 = d_Mode
    t_Value1 = d_Data
    
    Set t_SSET = ActiveDocument.SelectionSets.Add(d_SetName)
    ActiveDocument.SendCommand ("zoom all" + vbCr)
    t_SSET.Select vicSelectionSetAll, t_Point1, t_Point2, t_Code1, t_Value1 'Quan
'   t_SSET.Select vicSelectionSetInsideWindow, t_Point1, t_Point2, t_Code1, t_Value1 'was vicSelectionSetAll
    'ActiveDocument.SendCommand ("zoom p" + vbCr)
'--------QUAN-------
    Set SSetCreate = t_SSET
    
End Function
When I use F8 to step through the code, stopping at the final Set SSetCreate = t_SSET. I can place the mouse over t_Code1 and see it's value (2) and t_Value1 (DAPDRB00). but nothing for either point.

SteveN

Re: DVB file

#23
User Error!! I was trying to watch the complete expression, not individual components!!

Note: at this point the drawing contains a single rectangle -10,-10,0 to 310,210,0 (this is intended to be outside the search window)

I have placed watches on t_point1 & t_point2 and as I increment through the code, 1 returns 0,0,0 as double; 2 returns 300,200,0,as double.

Adding a watch to 't_SSET' in the closing statement Set SSetCreate = t_SSET gives me a count of zero and a name of "TEMP_SSET".

Now, adding a line from 50,50, to 250,150 (within the search window) and the incrementing through the code give:
Image
.

Sorry not the best image, but
t_SSET now has a count of 1 ? is this correct??

SteveN

Re: DVB file

#25
Hi Quan, Thanks

Made no difference :(

Did you want me to attache a copy of the "DAPDRB00" to this thread or the test drawing?

Steve

P.S.
Zip file attached containing drawing with "DAPDRB00" inserted & the vbi as it stands.
Attachments
SLN-DAP.zip
(103.56 KiB) Downloaded 438 times

Re: DVB file

#26
Hi Steve,

Please use this function to get the block in the attached drawing.

Code: Select all

Function SSetCreate(d_SetName As String, d_Mode As Integer, d_Data As String) As SelectionSet
    Dim t_SSET As SelectionSet

    Dim t_Point1 As Point
    Dim t_Point2 As Point
    Dim t_Code As Variant
    Dim t_Value As Variant
    
    Dim FilterType(0 To 0) As Integer
    Dim FilterData(0 To 0) As Variant
    FilterType(0) = d_Mode
    FilterData(0) = d_Data

    t_Code = FilterType
    t_Value = FilterData

    Set t_Point1 = Library.CreatePoint(0, 0)
    Set t_Point2 = Library.CreatePoint(12, 8)
    
    Set t_SSET = ActiveDocument.SelectionSets.Add(d_SetName)
    ActiveDocument.SendCommand ("zoom all" + vbCr) ' zoom to 0,0 12,8
    t_SSET.Select vicSelectionSetInsideWindow, t_Point1, t_Point2, t_Code, t_Value
    ActiveDocument.SendCommand ("zoom p" + vbCr)
    Set SSetCreate = t_SSET
    
End Function

Re: DVB file

#27
Many thanks Quan, that works :)

I did have to make a small change:

Code: Select all

    t_Code1 = FilterType
    t_Value1 = FilterData
I will spend some time over the weekend studying your changes to understand them more.

On a side note, the dwg in the zip was hurriedly created and used an imperial template, we are metric here in the UK so I have kept the window as 0,0 / 300,200.

SteveN

Re: DVB file

#28
I've moved on a little, though work is getting in the way!!

Next problem is associated with Attributes.
here is the code:

Code: Select all

Sub DynamicFormLoad(d_Form As Variant, d_Handle As String)
    Dim t_SREF As BlockInsert 					 'was AcadBlockReference
    Dim t_SATT As Variant
    Dim t_Index As Integer
    Dim t_FATT As Variant                                    	 'Dim t_FATT As Control
    Set t_SREF = ActiveDocument.HandleToObject(d_Handle)      'was ThisDrawing
    If (t_SREF.HasAttributes) Then
        t_SATT = t_SREF.GetAttributes
        For t_Index = LBound(t_SATT) To UBound(t_SATT)
            On Error GoTo DynamicFormLoad1
            Set t_FATT = d_Form.Controls.Item(t_SATT(t_Index).TagString)
            t_FATT.Text = t_SATT(t_Index).TextString
DynamicFormLoad2:
            On Error GoTo 0
            Next t_Index
        End If
    d_Form.Tag = d_Handle
    Exit Sub
DynamicFormLoad1:
    Resume DynamicFormLoad2
End Sub
I've shown the original code where I've made changes.
Current problem:

Code: Select all

        t_SATT = t_SREF.GetAttributes
.
doesn't work, and gives a 'runtime error 450'

This looks to be the same issue as here : viewtopic.php?t=3218&sid=8e104d3c0271ac ... 2a03891c76

Question: is it the same? & should I try to follow the solution in that thread?
NOTE: I have 50 attributes!!

SteveN

.

Re: DVB file

#30
Hi Quan,

I tried:

Code: Select all

    Dim t_FATT As Variant                                      'Dim t_FATT As Control
'    Set t_SREF = ActiveDocument.HandleToObject(d_Handle)      'was ThisDrawing
    If (t_SREF.HasAttributes) Then
    Set t_SREF = ActiveDocument.HandleToObject(d_Handle)      'was ThisDrawing
.

Same error message