C# data types

rhinocommon

#1

Hi,

I have a question. I could not find the answer.

In one of the code example on the website, we have a line:
Add annotation text:

Rhino.Geometry.Plane plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();

But when I replace it to this I will get an error.

Rhino.Geometry.Plane plane = Rhino.Display.RhinoViewport.ConstructionPlane();

I am looking for the topic of this error. I just have not found it yet. I searched under “custom type access c#” , “accessing classes” keywords etc.


#2

Is it the answer?

This method is instance, not static?


(jesterKing) #3

If you check the API documentation for RhinoViewport and scroll down to the method ConstructionPlane() you’ll find that it indeed is an instance method - most are. Mousing over the icon also tells you that:
kuva

Static methods on a class overview are marked with a fat superscript s:
kuva

ActiveViewport gives you an instance of RhinoViewport. If you want a different viewport than you’ll have to get the parent view from the views table doc.Views from the example and then use the ActiveViewport property.


#4

Thanks jesterKing,