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

Named views and Listboxes...

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
125 Views, 3 Replies

Named views and Listboxes...

Hello all, Right now my code will plot all P and L named views in a drawing (i.e. L1, L2, etc.). However, I was able to populate a ListBox with the View names, however, I cannot get the "names" of the selected items passed correctly to my PlotView sub. In UserForm Initialize to populate the ListBox (with Multiple selection enabled) with the VIEW names: For Each objView In objViews strView = objView.Name If strView Like "L#" Or strView Like "L##" Or strView Like "P#" Or strView Like "P##" Then lstViews.AddItem objView.Name End If Next objView Button on the form calls this sub. Public Sub PlotAllViews(pltMode As String) Dim objView As AcadView Dim objViews As AcadViews Dim strView As String Dim i As Integer Set objViews = ThisDrawing.Views For Each objView In objViews strView = objView.Name strView = Mid(strView, 2) intView = Val(strView) PlotView objView, pltMode Next objView End Sub However, I am trying to work this code into the PlotAllViews sub, so that ONLY the selected views in the ListBox are passed to the PlotView objView, pltMode line. I don't need my L and P string check anymore because I am doing that when the form initializes. Dim i As Integer If lstViews.ListIndex = -1 Then Exit Sub For i = lstViews.ListCount - 1 To 0 Step -1 If lstViews.Selected(i) = True Then Debug.Print lstViews.List(i) End If Next i
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

It's late, here, so I may be off the mark but I believe your code should be: Dim i As Integer If lstViews.ListIndex = -1 Then Exit Sub For i = lstViews.ListCount - 1 To 0 Step -1 If lstViews.Selected(i) = True Then Debug.Print lstViews.Text End If Next End If
Message 3 of 4
Anonymous
in reply to: Anonymous

I am getting a little closer. I am able to capture the name of the selected items from the listbox, i.e. L1, L2, etc. which are equivalent to named views in the drawing. However, lstViews.List(i) is a string and PlotView expects it as an object. I get this error now: Error 424 - Object required (see below <---HERE) Is there any way to "convert" the string of the view name captured from the listbox into the object that it expects ? Many thanks all. 'Sub Public Sub PlotView(objView As AcadView, pltMode As String) blah blah blah End Sub 'Command button Dim objView As AcadView Dim objViews As AcadViews Dim pltMode As String Dim i As Integer Set objViews = ThisDrawing.Views pltMode = "DOPREVIEW" If lstViews.ListIndex = -1 Then Exit Sub For i = lstViews.ListCount - 1 To 0 Step -1 If lstViews.Selected(i) = True Then PlotView lstViews.List(i), pltMode <---HERE End If Next i "Mike Tuersley" wrote in message news:t73nf9k41gk0.znzquoxifscn$.dlg@40tude.net... > It's late, here, so I may be off the mark but I believe your code should > be: > > Dim i As Integer > If lstViews.ListIndex = -1 Then Exit Sub > For i = lstViews.ListCount - 1 To 0 Step -1 > If lstViews.Selected(i) = True Then > Debug.Print lstViews.Text > End If > Next > End If
Message 4 of 4
Anonymous
in reply to: Anonymous

???maybe objViews.Item(viewnamestring) "News" wrote in message news:4058cee7_3@newsprd01... > Is there any way to "convert" the string of the view name captured from the > listbox into the object that it expects ?

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

Post to forums  

Autodesk Design & Make Report

”Boost