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