Create a panel that has access to ActiveDoc.Lights.Sun

I’m looking to create a panel in C# for Rhino where I’ll access the longitude and latitude of the drawing. To do so, I’m creating an user control that I want to include in my panel (that is also a user control)
I do not know if I can embed as sub-panel the Sun Panel that already exist (if yes, how?) or if as I’m trying, I can create my own panel and have a Rhino.Render.Sun variable in my code (what I’m trying to do). The issue is when I’m trying to initialize the variable with Rhino.RhinoDoc.ActiveDoc.Lights.Sun, I’m getting an error that that the dll rhcommon_c cannot be load. When I try to add the dll in the references, Visual Studio 2013, the system tells me it is not a valid COM component…

I’m able to code but I won’t say that I know how to code. I am clearly out of my comfort zone here, but I would like to make it work. Any advise?

Thanks a lot

PS: I have seen that going through ActiveDoc is not a great idea. Still I have to understand how to go around it. So if there’s a way to use it, it would be great.

rhcommon_c.dll is not a .NET assembly, so you cannot reference it.

Do you have some sample code we can look at?


– Dale

Here what I did (I do not have the code anymore, but if needed, I’ll rewrite it. It is not that difficult). I actually took your example SampleCsPanel and created another UserControl in witch I created a variable Rhino.Render.Sun . I have the issue when, with the designer, I try to put this new user control in the panel you provide with your sample.

The error that you are seeing is a common problem with Windows Forms and the designer. The designer is attempting to actually run some code to display a preview of your panel and that code is attempting to call code that exists in Rhino (which is not available at design time.) You can use the DesignMode property on the form to test if the code is executing in the designer or actually in Rhino. Use that property to protect from calling things like ActiveDoc.Lights.Sun