Re: DVB file

#46
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
Attachments
SLN.rar
(58.41 KiB) Downloaded 7 times

Re: DVB file

#48
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

#50
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.
Attachments
SLN-DAP-19-12-22.zip
(101.99 KiB) Downloaded 7 times

Re: DVB file

#52
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

#53
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 133 times
cron