Page 4 of 4

Re: DVB file

Posted: Thu Dec 08, 2022 3:41 am
by sln8458
Fired up my win 10 pro laptop, same error!
So that is 3 computers, 2xwin 10 & the new win11 PC with the same issue.

Not sure how Quan doesn't get the same problem?

I've attached a copy of my vbi file.
(it's the 'BORDER - Sub SLN_ProjectDetailsShow() )

SteveN

Re: DVB file

Posted: Thu Dec 08, 2022 8:44 am
by QuanNguyen
Hi Steven,

It works on both Win 10 and 11 too.
Please refer to the attached.
Regards,
TEST DRAWING.zip
(31.26 KiB) Downloaded 204 times

Re: DVB file

Posted: Thu Dec 08, 2022 9:28 am
by sln8458
Hi Quan,

Once again thankyou.

Your code does work, however i can see a number of changes prior to the specific line that is causing my problem(s).

It's very clear that the problem in me and my lack of knwledge :(

SteveN

Re: DVB file

Posted: Thu Dec 08, 2022 6:39 pm
by QuanNguyen
You're welcome, Steven.

Re: DVB file

Posted: Mon Dec 19, 2022 9:17 am
by sln8458
Back for more help.

I have moved on to a new module, The block insert function, yes I know there is a command for this in Icad, but the person using this has NO CAD experience and is used to using this specific set of tools.

I've added the current vbi file below.

Starting here:

Code: Select all

Public Sub SLN_BLOCKinsert()
The code seems to work upto displaying the form for selecting the block to insert.

I can select a block and the code steps through ok using F8 untill here:
(the last line before Icad crashed is t_index = 0)

Code: Select all

Private Sub BlockInsert()
    Dim t_SSET As SelectionSet          ' was AcadSelectionSet
    Dim t_FileSystem
    Dim t_FileName As String
    Dim t_LayerCurrent As String
    Dim t_Index As Long
    Call SSetDeleteAll
    t_Index = 0
    While t_Index < ThisDocument.Layers.Count        'was ThisDrawing.Layers.Count***************CRASH ICAD
        If ((ThisDocument.Layers(t_Index).Name <> "0") And (ThisDocument.Layers(t_Index).Name <> "B") And (ThisDocument.Layers(t_Index).LayerOn = True)) Then t_LayerCurrent = ThisDocument.Layers(t_Index).Name
            t_Index = t_Index + 1
So why does Icad crash out??
What is the problem?

SteveN.

Re: DVB file

Posted: Tue Dec 20, 2022 6:11 pm
by QuanNguyen
Hi Steven,

Please use ActiveDocument instead of ThisDocument.

Code: Select all

ActiveDocument.Layers.Count
Regards.

Re: DVB file

Posted: Wed Dec 21, 2022 6:17 am
by sln8458
Thanks Quan,

changed to this:

Code: Select all

Private Sub BlockInsert()
    Dim t_SSET As SelectionSet          ' was AcadSelectionSet
    Dim t_FileSystem
    Dim t_FileName As String
    Dim t_LayerCurrent As String
    Dim t_Index As Long
    Call SSetDeleteAll
    t_Index = 0
    While t_Index < ActiveDocument.Layers.Count        'was ThisDrawing.Layers.Count
        If ((ActiveDocument.Layers(t_Index).Name <> "0") _
        And (ActiveDocument.Layers(t_Index).Name <> "B") _
        And (ActiveDocument.Layers(t_Index).LayerOn = True)) _
        Then t_LayerCurrent = ActiveDocument.Layers(t_Index).Name
            t_Index = t_Index + 1
'        End If
    Wend
    t_FileName = DAP_IBLOCK.P.Text
    If (Right$(t_FileName, 1) <> "\") Then t_FileName = t_FileName + "\"
        t_FileName = t_FileName + Me.N.Text
        Set t_FileSystem = CreateObject("Scripting.FileSystemObject")
        If (t_FileSystem.fileexists(t_FileName)) Then
            If (t_LayerCurrent <> "") Then
                ActiveDocument.Layers("B").LayerOn = True     ' was ThisDrawing
                ActiveDocument.SendCommand ("CLAYER B" + vbCr)     ' was ThisDrawing
                DAP_IBLOCK.hide
                ActiveDocument.SendCommand ("-insert " + t_FileName + vbCr + "0,0,0" + vbCr + "1" + vbCr + "1" + vbCr + "0" + vbCr)     ' was ThisDrawing
                Set t_SSET = SSetCreate("DAP_BR", 8, "B")
                If (t_SSET.Count = 1) Then
                    t_SSET.Item(0).Explode
                    t_SSET.Item(0).Delete
                    t_SSET.Delete
                    Set t_SSET = SSetCreate("DAP_BR", 8, "B")
'                    If (t_SSET.Count > 0) Then
'                        Call InsertReference
'                        For t_Index = 0 To t_SSET.Count - 1
'                            t_SSET.Item(t_Index).Layer = t_LayerCurrent
'                        Next t_Index
'                        ThisDocument.SendCommand ("CLAYER " + t_LayerCurrent + vbCr)     ' was ThisDrawing
'                        ActiveDocument.Layers("B").LayerOn = False     ' was ThisDrawing
'                        ActiveDocument.SendCommand ("move" + vbCr + "P" + vbCr + vbCr + "0,0,0" + vbCr)     ' was ThisDrawing
'                    End If
                End If
            End If
        Else
            MsgBox "This file does not exist", 16, "ERROR"
        End If
'    End If
End Sub
This code works and the selected drawing is inserted, as required.
What is the difference between ThisDocument & ActiveDocument, i'm unable to find anything in the Icad help files.

Also
I've commented out the 'if' for the InsertReference for the time being as I didn't understand why it is there, when I can see the block has beeninserted into the drawing.
plus it has another chunk of code to struggle with.

SteveN

Re: DVB file

Posted: Wed Dec 21, 2022 6:57 pm
by QuanNguyen
Hi Steven,

The ActiveDocument is the IntelliCAD active document object.
The ThisDocument means the same as in the past but didn't use in the current version.
(unlucky, some sample codes in official documents still use the ThisDocument, so it causes the confused for users.)

Regards,
ActiveDocument.png
ActiveDocument.png (43.58 KiB) Viewed 8074 times

Re: DVB file

Posted: Thu Dec 22, 2022 1:33 am
by sln8458
Thanks Quan,

So for correctness it would be better to replace 'ThisDocument' with 'ActiveDocument' in ALL code modules etc.

SteveN

Re: DVB file

Posted: Mon Feb 27, 2023 1:13 am
by sln8458
I am struggling to make progress with this, I have to accept defeat :(

Is anyone able to help? possibly for a fee $/£??
By help I mean take the project on to completion.

SteveN