List all view scale on current sheet

List all view scale on current sheet

stefano.cartaKGT96
Advocate Advocate
1,504 Views
7 Replies
Message 1 of 8

List all view scale on current sheet

stefano.cartaKGT96
Advocate
Advocate

Hi guys..

 

I would to make a list of all view on the current sheet and find relative view scale.

 

 

 csheet = doc.ActiveView
 For Each vw As Viewport In csheet.view


  Next

 

I thinking to use this..but  csheet.view is not correct..

Where I can find a sample? What approch I have to follow?

thanks

Stefano

0 Likes
Accepted solutions (1)
1,505 Views
7 Replies
Replies (7)
Message 2 of 8

ridaabderrahmane
Enthusiast
Enthusiast

First cast your active view to a ViewSheet using : 

var sheet = doc.ActiveView as ViewSheet

then use sheet.GetAllPlacedViews() to find the views placed on your sheet.

0 Likes
Message 3 of 8

stefano.cartaKGT96
Advocate
Advocate

thanks!!

some like this? but how  can read the scale of vw?

  Dim CTAV As ViewSheet = doc.ActiveView
  Dim LISTVIEW As IList(Of Viewport) = CTAV.GetAllPlacedViews()

        For Each vw As Viewport In LISTVIEW


        Next

 

 

0 Likes
Message 4 of 8

ridaabderrahmane
Enthusiast
Enthusiast

view.Scale 

0 Likes
Message 5 of 8

stefano.cartaKGT96
Advocate
Advocate

sorry..but I have problem with the view.scale

in the for each I can't utilize viwp.scale because scale is not a member of viwp

 

 Dim CTAV As ViewSheet = doc.ActiveView
        Dim LIST As IList(Of Viewport) = CTAV.GetAllPlacedViews()

        For Each viwp As Viewport In LIST

            

        Next

 

0 Likes
Message 6 of 8

peteregan
Contributor
Contributor

I work in C# - I think this is it:

    For Each viwp As Viewport In LIST
		Dim view as View = doc.GetElement(viwp.OwnerViewId)
		Dim sc as Double = view.Scale
		...
	Next

 

0 Likes
Message 7 of 8

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Hi @stefano.cartaKGT96 ,

 

GetAllPlacedViews  returns a list (Iset) of Elementid's not Viewport elements

 

See fragment below, this retrieves all unique scales.

If TypeOf (doc.ActiveView) Is ViewSheet Then
	Dim VS As ViewSheet = CType(doc.ActiveView, ViewSheet)
	
	Dim ViewScales As New List(Of Integer)
		For Each ViewId As ElementId In VS.GetAllPlacedViews
			Dim ViewElem As View = CType(doc.GetElement(ViewId), View)
			Dim Scale As Integer = ViewElem.Scale
			If Not (ViewScales.Contains(Scale)) Then ViewScales.Add(Scale)
		Next

	'ViewScales.Distinct 'Or use distinct after all scales are added.

End If

 

 - Michel

0 Likes
Message 8 of 8

stefano.cartaKGT96
Advocate
Advocate

Hi...

Tomorrow I will try your code...

Thanks

0 Likes