Hamidreza1973
Industrial
- Feb 5, 2022
- 15
Dear All,
Please kindly review my code. Within this code, the program first asks the user that, how many layouts he wants. Then create them and make them empty. then execute the "Mview" command to ask the user for the first view selection but after this time the program will be ended and don't ask the user for the selection of the other view to another layout.
Private Sub Create_Empty_layout()
Dim currentLayout As AcadLayout
Dim LayoutName As String
Dim NumberofLayouts As Integer, NumberofRequired As Integer, Count As Integer
Dim I As Integer
ThisDrawing.ActiveSpace = acPaperSpace
NumberofRequired = UserForm1.TextBox1.Text
'Delete all current layout except "Model" layout
For Each currentLayout In ThisDrawing.Layouts
LayoutName = currentLayout.Name
If LayoutName <> "Model" Then currentLayout.Delete
Next
'No need to create layout1 beacuse its atomatically created after deleting all layouts
'Just delete the content
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout1")
For Each objAcadObject In ThisDrawing.PaperSpace
If TypeName(objAcadObject) = "IAcadPViewport" Then objAcadObject.Delete
Next
'Now we have to create from layout2 up to number of required ones
'Just delete the content
For Count = 2 To NumberofRequired
ThisDrawing.Layouts.Add ("Layout" & Count)
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout" & Count)
For Each objAcadObject In ThisDrawing.PaperSpace
If TypeName(objAcadObject) = "IAcadPViewport" Then objAcadObject.Delete
Next
Next
UserForm1.Hide
For I = 1 To NumberofRequired
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout" & I)
With ThisDrawing.Utility
.InitializeUserInput 0, "Mview Cancel"
ThisDrawing.SendCommand "_Mview _New" & vbCr
End With
Next I
End Sub
Please kindly review my code. Within this code, the program first asks the user that, how many layouts he wants. Then create them and make them empty. then execute the "Mview" command to ask the user for the first view selection but after this time the program will be ended and don't ask the user for the selection of the other view to another layout.
Private Sub Create_Empty_layout()
Dim currentLayout As AcadLayout
Dim LayoutName As String
Dim NumberofLayouts As Integer, NumberofRequired As Integer, Count As Integer
Dim I As Integer
ThisDrawing.ActiveSpace = acPaperSpace
NumberofRequired = UserForm1.TextBox1.Text
'Delete all current layout except "Model" layout
For Each currentLayout In ThisDrawing.Layouts
LayoutName = currentLayout.Name
If LayoutName <> "Model" Then currentLayout.Delete
Next
'No need to create layout1 beacuse its atomatically created after deleting all layouts
'Just delete the content
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout1")
For Each objAcadObject In ThisDrawing.PaperSpace
If TypeName(objAcadObject) = "IAcadPViewport" Then objAcadObject.Delete
Next
'Now we have to create from layout2 up to number of required ones
'Just delete the content
For Count = 2 To NumberofRequired
ThisDrawing.Layouts.Add ("Layout" & Count)
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout" & Count)
For Each objAcadObject In ThisDrawing.PaperSpace
If TypeName(objAcadObject) = "IAcadPViewport" Then objAcadObject.Delete
Next
Next
UserForm1.Hide
For I = 1 To NumberofRequired
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Layout" & I)
With ThisDrawing.Utility
.InitializeUserInput 0, "Mview Cancel"
ThisDrawing.SendCommand "_Mview _New" & vbCr
End With
Next I
End Sub