I Want to change the View of viewport according to the Combobox change event. the drawing is updating only after exiting the macro. My aim is to view my 3D object in different views and to modify it.
Here is my code.
Private Sub UserForm_Initialize()
ComboBox1.AddItem "Top"
ComboBox1.AddItem "Left"
ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Change()
ThisDrawing.SendCommand "-View" & vbCr & ComboBox1.Text & vbCr
ThisDrawing.Regen acActiveViewport
End Sub
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Your code almost good
You may want to use instead this example:
'' Module frmViews Option Explicit Private Sub CommandButton1_Click() Dim vw As String vw = Me.ComboBox1.Text Dim cmd As String cmd = "-View" & vbCr & vw & vbCr ThisDrawing.SendCommand cmd End End Sub Private Sub UserForm_Initialize() ComboBox1.AddItem "_Top" ComboBox1.AddItem "_Bottom" ComboBox1.AddItem "_Left" ComboBox1.AddItem "_Right" ComboBox1.AddItem "_Front" ComboBox1.AddItem "_Back" ComboBox1.AddItem "_Swiso" ComboBox1.AddItem "_Seiso" ComboBox1.AddItem "_Nwiso" ComboBox1.AddItem "_Neiso" ComboBox1.ListIndex = -1 End Sub '' Module modViews Option Explicit Sub RunMe() Dim frm As frmViews Set frm = New frmViews frm.Show End Sub
Thank you,
The result is the same, The view is changing on exit, not with the click event.
I need view to be changed while Form is active, so that I can Align autocad objects in different views with the use of form controls
with regards
To do it just to change button code:
Private Sub CommandButton1_Click() Dim vw As String vw = Me.ComboBox1.Text Dim cmd As String Me.Hide cmd = "-View" & vbCr & vw & vbCr ThisDrawing.SendCommand cmd Me.Show End Sub