Background Info
Currently I am updating a plug-in that ran fine with Rhino 6.
The plugin is accessed external as described here:
with further info from
https://developer.rhino3d.com/api/rhinoscript/introduction/external_access.htm
update V6-V8
(I did not manage to update the existing solution / project.) so my approach was:
I started a new Project from the Rhino Visual Studio Template, copied / added all files and renamed
- plugin
- new guid for the plugin
- Com-visible-Class
it also seams that all it is important that everything is targeting the same dot-net version.
Might be that not all above steps are necessary.
Issues
Layer Panel not updating
Referring to above github sample - the following modification allows to reproduce the current error:
Use the external (console) App to call the plug-in that will add a new layer with a single line - the layerpanel does not update / not show the new layer.
Add to SampleCsRhinoObject.cs
/// <summary>
/// add a line on a new layer
/// </summary>
public bool AddLineOnNewLayer()
{
RhinoDoc doc = RhinoDoc.ActiveDoc;
// find name
int i = 0;
bool search = true;
string layName = "not set";
while (search)
{
layName = "new_" + i.ToString();
Layer findLayer = doc.Layers.FindName(layName);
if (findLayer != null)
{
i++;
}
else
{
search = false;
}
}
// add layer
int index = doc.Layers.Add(layName, System.Drawing.Color.DarkBlue);
// make layer invisible
doc.Layers[index].IsVisible = false;
// add an object to the hidden layer - in the original project this was a debugging purpose
Guid objId = doc.Objects.AddLine(new Point3d(0, 0, 0), new Point3d(111, 222, 333), new ObjectAttributes() { LayerIndex = index });
return objId != Guid.Empty;
}
now in the console App
bool success = plugin.AddLineOnNewLayer();
if I call the same Function from a command within Rhino - everything works fine, the layer panel updates
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
SampleCsRhinoObject pluginObj = new SampleCsRhinoObject();
pluginObj.AddLineOnNewLayer();
return Result.Success;
}
Rhino Background Task
a second Issue:
after debugging above solution and close Rhino, a (invisible) Background task “Rhino” stays in the taskmanager.
If I not close it / end it before the next debugging - I get some null-pointer-execeptions…
File
the following file / solution is a bit of a collage / bricolage / copy paste … and more the result of my error-search then it should be a nice, tidy sample…
cs_SampleCsAutomationV8.zip (460.6 KB)