December 17, 2019, 1:58 am
@lucabrasi wrote:
Hi,
Do you know if Rhino has a log? I’m trying to load my plugin, and in Rhino works, but using my Skin drops that error:
System.Exception: No PlugIn subclass found.
at Rhino.PlugIns.PlugIn.CreateFromAssembly(Assembly pluginAssembly, Boolean displayDebugInfo, Boolean useRhinoDotNet)
I’m trying to figure out what can be the problem. ![:slight_smile: :slight_smile:]()
Thanks,
Posts: 1
Participants: 1
Read full topic
↧
December 17, 2019, 2:04 am
@Alberto wrote:
Hi,
we are trying to create a command that selects only trianglular faces for a given mesh. I prototype that in python looking at a pre-existing forum entry and everything is working nice and dandy. Now I created the C# code for that and it does not behave the same way. Any idea why this is? Am I missing a command style or some settings?
public class TriangleSelectCmd : Command
{
static TriangleSelectCmd _instance;
public TriangleSelectCmd()
{
_instance = this;
}
public static TriangleSelectCmd Instance
{
get {
return _instance;
}
}
public override string EnglishName
{
get {
return "SelectTriangles";
}
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var objects = new List<MeshObject>();
RhinoGet.GetOneObject("Get Mesh", false, ObjectType.Mesh, out var objref);
SelectFaces(objref.Object() as MeshObject, true);
doc.Views.Redraw();
return Result.Success;
}
private void SelectFaces(MeshObject obj, bool selectTris)
{
var mesh = obj.MeshGeometry;
for (int i = 0; i < mesh.Faces.Count; ++i) {
var componentIndex = new ComponentIndex(ComponentIndexType.MeshFace, i);
if (selectTris && mesh.Faces[i].IsTriangle) {
obj.SelectSubObject(componentIndex, true, true, true);
} else if (!selectTris && mesh.Faces[i].IsQuad) {
obj.SelectSubObject(componentIndex, true, true, true);
}
}
}
}
Posts: 1
Participants: 1
Read full topic
↧
↧
December 17, 2019, 5:27 am
@michaldengusiak wrote:
We are struggling to generate a surface from Planar Closed Polyline. Currently, for more than 4 edges shape is not correct. How should we improve it? Any help really appreciated
//Create surfaace from planar polyline points
public static Rhino.Geometry.Brep ToBrep(this IEnumerable<Rhino.Geometry.Point3d> points)
{
List<Rhino.Geometry.Point3d> pointList = new List<Rhino.Geometry.Point3d>(points);
//---Not necessary---
Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(pointList[0], pointList[1], pointList[2]);
points = pointList.ConvertAll(x => plane.ClosestPoint(x));
//-------------------
List<Rhino.Geometry.LineCurve> lineCurves = new List<Rhino.Geometry.LineCurve>();
// Create Line Curve
for (int i = 1; i < pointList.Count; i++)
lineCurves.Add(new Rhino.Geometry.LineCurve(pointList[i - 1], pointList[i]));
lineCurves.Add(new Rhino.Geometry.LineCurve(pointList.Last(), points.First()));
//Ceate Surface
return Rhino.Geometry.Brep.CreateEdgeSurface(lineCurves);
}
GH approach
Our approach
Posts: 3
Participants: 2
Read full topic
↧
December 17, 2019, 10:26 am
@pythonuser wrote:
Hi;
What’s wrong with my code ?
void RhinoUpdateObjectGroups(CRhinoObject* obj)
{
ON_ClassArray<ON_SimpleArray<int>> gmap;
int attrib_group_count = obj->Attributes().GroupCount();
if (attrib_group_count > 0)
{
CRhinoObjectAttributes attributes = obj->Attributes();
ON_SimpleArray<int> group_indexes;
const int group_count = attributes.GetGroupList(group_indexes);
if (group_indexes.Count() > 0)
{
if (group_count > 0)
{
if (gmap.Count() == 0)
{
ON_SimpleArray<int> g;
for (int i = 0; i < group_count; i++)
{
g.Append(-1);
gmap.Append(g);
}
}
for (int i = 0; i < attrib_group_count; i++)
{
int old_group_index = group_indexes[i];
int new_group_index = gmap[old_group_index][0];
if (new_group_index == -1)
{
new_group_index = obj->Document()->m_group_table.AddGroup();
gmap[old_group_index][0] = new_group_index;
}
group_indexes[i] = new_group_index;
}
attributes.RemoveFromAllGroups();
for (int i = 0; i < attrib_group_count; i++)
attributes.AddToGroup(group_indexes[i]);
RhinoApp().ActiveDoc()->ModifyObjectAttributes(obj, attributes);
}
}
}
}
Posts: 2
Participants: 2
Read full topic
↧
December 18, 2019, 4:06 am
@Goswin wrote:
Ist there a way to know if Brep.CreateBooleanDifference
did actually subtract anything from the input brep?
Lets say the brep and the trimmer are just touching each other.
Even if the returned brep is the same as the input , calling Object.ReferenceEquals
returns always false.
Would I first have to compute CreateBooleanIntersection
and see if it returns anything ?
Since these calls can be expensive I would like to avoid that.
Posts: 5
Participants: 4
Read full topic
↧
↧
December 18, 2019, 4:41 am
@Petras_Vestartas wrote:
Hi,
I am compiling .dll library with some geometry helper functions.
I am not running the project in debugging mode. Just would like to add or change some bits of code in my .dll while working without restarting rhino.
The problem is that when I want to compile the code I need to close rhino else I get error in visual studio:
Could not copy "obj\Debug\RhinoJoint.dll" to "..\..\..\..\..\AppData\Roaming\Grasshopper\6\Libraries\RhinoJoint\RhinoJoint.dll". Exceeded retry count of 10. Failed. The file is locked by: "Rhino 6 (2364)" RhinoJoint
The .dll is loaded in grasshopper C# script editor, ideally I would like to update the .dll while working, but restarting rhino is what I would like to avoid.
Is there any workaround?
Posts: 3
Participants: 3
Read full topic
↧
December 18, 2019, 6:41 am
@software_comas wrote:
Hi guys!
I’m trying to create a “special version” of the offset command, using RhinoCommon.
I’m trying to use these methods:
- Curve.Offset(Plane, Double, Double, CurveOffsetCornerStyle)
- Curve.Offset(Point3d, Vector3d, Double, Double, CurveOffsetCornerStyle)
I’ve noticed that these methods are less reliable of Rhino “_Offset” command.
More in detail, I’ve found that, in some cases, those methods simply fail (they return null) while the standard Rhino command succeed… Of course using the same working parameters, where possible.
More in general, I would like to know what’s the best way to react to a null result or to a multiple curves result.
Can you help me, please?
Thanks
Sebastiano
Posts: 2
Participants: 2
Read full topic
↧
December 18, 2019, 10:10 am
@Jarek wrote:
I am looking for a way to completely hide the cursor in Rhino via Python/RhinoCommon script.
Similar way to this WinApi function would do it:
I tried using System.Windows.Forms and ShowCursor/HideCursor, but it doesn’t work globally in Windows.
Any ideas?
I’d like to have run one script that hides the cursor, and another one that shows it, if at all possible.
Thank you,
Jarek
Posts: 1
Participants: 1
Read full topic
↧
December 18, 2019, 8:18 pm
@Jarek wrote:
Hi @stevebaer,
Since you were the one fixing with how RhinoScript / RunScript works and make sure it works inside Rhino commands, I figured I would ask you again since I have ran into similar issue with RunPythonScript. The issue is RhinoScripts work fine when run from button or compiled plugin inside other commands but Python scripts don’t.
Take a sample button like this:
Both work just fine when ran from a button on their own (no other commands running)
However, when, for example I start drawing a Polyline and run the RhinoScript one, all works fine: script prints to command line and then we can continue to draw; Python version fails: command line looks like this:
Unknown command: (
print("Python 1")
print("Python 2")
print("Python 3")
)
Would it be possible to make the RunPythonScript command work as well as the RunScript one, and let us run Python scripts inside other commands (as a fix in Rhino 6 SR…) ?
thank you,
–jarek
Posts: 1
Participants: 1
Read full topic
↧
↧
December 19, 2019, 5:17 am
@marton.parlagh wrote:
In Rhino there are different ways to edit materials/environments, and handling these from the plugin is bit different (dependent on the actual mode), which causes problem here.
Normally in case the user edits the Custom Material from the Material panel. In this case every change happens instantly. But it is also possible to edit the material from a Modal Dialog (for example “Layer Material”) and in this case only after the user clicks on the OK button should the plugin accept the new values, but from the Eto Collapsible form it is not visible. I mean the plugin has no idea about the mode the material is edited and how to handle the change. (Also it knows nothing about what button the user clocks at the and - OK or Cancel).
What is the correct way to handle it? Maybe I could try to investigate what kind if dialog is on the top, and this could be a sign for the plugin how to handle changes, but it is a bit messy solution.
Márton
Posts: 1
Participants: 1
Read full topic
↧
December 19, 2019, 7:31 am
@dick.lelyveld wrote:
Does anybody know how to set the background color of a panel using Python Eto?
There is no property BackgroundColor for an Eto.Forms.Panel
, but as I understand a panel is ultimately an Eto.Forms.Control
, which does have this property.
Unfortunately this does not work:
panel = Eto.Forms.Panel()
panel.BackgroundColor = Eto.Drawing.Colors.Blue
How would I go about this?
Posts: 1
Participants: 1
Read full topic
↧
December 19, 2019, 8:26 am
@Robert wrote:
with Rhino 5 common work like this
starter form = new starter();
if (mode == RunMode.Interactive)
{
form.ShowDialog(RhinoApp.MainWindow());
RhinoApp.WriteLine(form.result);
}
but how it work with rh6 Commeon
Thanks Robert
Posts: 1
Participants: 1
Read full topic
↧
December 19, 2019, 9:02 am
@SteveP wrote:
Sorry but yet another thing that’s bugging me and that I can’t figure out.
The developers kit lists this method for polylines:
CenterPoint Compute the center point of the polyline as the weighted average of all segments.
Here is a polyline set at the origin (the center is a point placed at the center Osnap):
![Poly1]()
Here is the excel calculation for the 8 line segments:
![Poly2]()
So why does Rhino show (2, 2.25) for the centre and excel has (2.11, 2.39)?
SteveOh
Posts: 4
Participants: 2
Read full topic
↧
↧
December 20, 2019, 5:06 am
@Goswin wrote:
I know similar issues have been reported before.
I use these settings to mesh more than thousand solid Breps that I created before programatically.
Meshing fails on two of them.
two of four Breps fail to mesh in RhinoCommon.3dm (1.6 MB)
open Rhino.Geometry
let meshing =
let m = MeshingParameters.FastRenderMesh
m.JaggedSeams <- false
m.ClosedObjectPostProcess <- true
m
for guid in rs.ShownObjects() do
let brep = rs.CoerceBrep(guid)
let mesh = new Mesh()
Mesh.CreateFromBrep(brep,meshing) |> Seq.iter mesh.Append
print mesh.IsValid
I could narrow the problem down a bit:
I am on Rhino 6.20.19322.20361
Posts: 2
Participants: 2
Read full topic
↧
December 22, 2019, 9:13 pm
@jerry1 wrote:
Hi every one, for some reasons, I hope the top and perspective view could
rotate 180 degree by y-axis, and give the nameview-top1, perspective1.
and the following code can finish this work.
Dim num As Integer
num = RhinoDoc.ActiveDoc.Views.Count
Dim vp11(num - 1) As Rhino.Display.RhinoView
For i = 0 To num - 1
vp11(i) = RhinoDoc.ActiveDoc.Views.ElementAt(i)
If vp11(i).ActiveViewport.Name = “Perspective” Then
vp3 = vp11(i)
vp3.ActiveViewport.Rotate(PI, VECC, pt0)
End If
If vp11(i).ActiveViewport.Name = “Top” Then
vp2 = vp11(i)
vp2.ActiveViewport.Rotate(PI, VECC, pt0)
End If
Next
RhinoDoc.ActiveDoc.NamedViews.Add(“Perspective1”, vp3.ActiveViewport.Id)
RhinoDoc.ActiveDoc.NamedViews.Add(“Top1”, vp2.ActiveViewport.Id)
RhinoDoc.ActiveDoc.Views.Redraw()
But the active view maybe exist two perspectives and the top is disappear in some situations, and I must to find top view information from the viewtable list (see the following figure) , could anyone tell me how to write the program to obtain the all
views information(not only limit the active document)
Posts: 1
Participants: 1
Read full topic
↧
December 22, 2019, 10:07 pm
@ongys1992 wrote:
I’m wondering what is the type of characters allowed in the GetBaseClass.AddOptionList Method’s parameter of listValues.
In Rhinocommon, it states that it simply states:
Type: System.Collections.Generic.IEnumerable
The string values.
However, after testing, it appears that spaces and certain characters aren’t allowed.
Would greatly appreciate if there was a list of characters that aren’t allowed.
Posts: 1
Participants: 1
Read full topic
↧
December 23, 2019, 3:05 am
↧
↧
December 23, 2019, 1:40 pm
@andresobregonlopez wrote:
Dear C# Friends!
I would like to divide a Curve and generate a list of Planes,
How could I align the planes as Gh Component Perp Frames does it?
I try to Rotate them (plane.Rotate) but How you could compute a delta Vector3d for all the planes?
Thanks!
private void RunScript(Curve curve, int n, bool alignPlanes, ref object A, ref object B, ref object C)
{
//Create an Array of Point3d
//var points = new Point3d[n+1];
Point3d[] points;
var p = curve.DivideByCount(n, true, out points);
List<Plane> planes = new List<Plane>();
List<Vector3d> vN = new List<Vector3d>();
// How to comoute a Delta Vector??
Vector3d vectorDelta = new Vector3d(Vector3d.ZAxis);
for (int i = 0; i < n + 1 ; i++){
vN.Add(curve.TangentAt(p[i]));
Plane plane = new Plane(points[i], vN[i]);
// HOw to align all the planes as Perp Frames Gh Component does?
if (alignPlanes){plane.Rotate(0, vN[i]);}
planes.Add(plane);
}
A = points;
B = vN;
C = planes;
}
CurveDivideByCount-CurveTangentAt.gh (17.1 KB)
Posts: 2
Participants: 2
Read full topic
↧
December 24, 2019, 6:10 am
@theanhkc07 wrote:
Hi everyone. I created a RHI file from the .py file with rhinoscripcompiler, but when I ran a command from rhino’s command, an error occurred when I had to press esc to complete the command. Compared with the runpythonscrip and the newly created command, the command must press esc to complete the command.MultiUnroll.py (7.4 KB) MultiUnroll.rhi (11.1 KB)
Posts: 1
Participants: 1
Read full topic
↧
December 26, 2019, 3:22 am
@cavasct wrote:
Hi, i would like to know if there is any command from RhinoPython which I can use for joining different objects (points, curves, …) in order to move them together.
Thanksss!!
Posts: 4
Participants: 3
Read full topic
↧