VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Change view using Combobox

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
MakCADD
775 Views, 5 Replies

How to Change view using Combobox

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

 

5 REPLIES 5
Message 2 of 6
Hallex
in reply to: MakCADD

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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 6
MakCADD
in reply to: Hallex

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

Message 4 of 6
Hallex
in reply to: MakCADD

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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 6
MakCADD
in reply to: Hallex

thank you

 

it works

 

 

Message 6 of 6
Hallex
in reply to: MakCADD

Glad I could help
Cheers 🙂
_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost