Drawing iLogic - Place Views Using For Loop

lukerNEVB8
Observer
Observer

Drawing iLogic - Place Views Using For Loop

lukerNEVB8
Observer
Observer

Hello,

I have the following code as an example, is there correct syntax for me to say:

For i = 1 to 4

     oView & i = oSheet.DrawingViews.Item(i)

Next

 

Dim oView1, oView2, oView3, oView4 As DrawingView 
oView1 = oSheet.DrawingViews.Item(1)
oView2 = oSheet.DrawingViews.Item(2)
oView3 = oSheet.DrawingViews.Item(3)
oView4 = oSheet.DrawingViews.Item(4)

 

I cannot seem to find a way to get iLogic to reference oView1 in this way. Code later creates workpoints and centerpoints and ideally I want to do the same thing.

 

Thanks!

0 Likes
Reply
423 Views
1 Reply
Reply (1)

JelteDeJong
Mentor
Mentor

You might have  a look at arrays. you could do something like this:

Dim oView(sheet.DrawingViews.Count) As DrawingView
For i = 1 To sheet.DrawingViews.Count
    oView(i) = sheet.DrawingViews.Item(i)
Next
For Each currentView As DrawingView In oView
    ' Arrays have also a element 0. 
    ' We did only set elements 1 to 4. 
    ' There for element 0 is nothing. and we have 
    If (currentView Is Nothing) Then Continue For
    MsgBox(currentView.Name)
Next

There is alos a easyer way to fill the array. If you use this then you elements 0 to 3 are filled. (computers usally start counting with 0)

Dim oView() As DrawingView = sheet.DrawingViews.Cast(Of DrawingView).ToArray()
For Each currentView As DrawingView In oView
    MsgBox(currentView.Name)
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes