October 8, 2018, 11:50 pm
@DominikIC wrote:
Hi all,
within a plugin I was trying to explode linked block to use its components.
It all works fine with single standard blocks. But nested linked problems causes some problems.
As an example:
file A and file B are inserted in file C as linked blocks.
When using C as linked block in file D and exploding this block the result is obviously having linked blocks A and B in D. Unfortunately there is always ONE of these resulting blocks that is document controlled and can not be moved, deleted or edited in whatever way. It stays there where it is. Only by closing and opening the file this block will gone…
Code snippet (within a command):
ObjRef objRef = RS.RNGet.GetObject(“get block”, ObjectType.InstanceReference);
ObjRef[] objRefs;
Rhino.Input.Custom.GetObject go;
go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt(“get instance object”);
go.GeometryFilter = ObjectType.InstanceReference;
go.SubObjectSelect = false;
go.AcceptNothing(true);
//go.GetMultiple(1,0);
go.Get();
if (go.CommandResult() != Rhino.Commands.Result.Success)
return Result.Cancel;
objRef = go.Object(0);
if (objRef == null)
{
return Result.Cancel;
}
InstanceObject instObj = objRef.Object() as InstanceObject ;
if(instObj==null)
{
return Result.Cancel;
}
RhinoObject[] explodedObjects;
ObjectAttributes[] attributesOfExplodedObjects;
Transform[] transformOfExplodedObjects;
instObj.Explode(false, out explodedObjects, out attributesOfExplodedObjects, out transformOfExplodedObjects);
Guid[] IDs = new Guid[explodedObjects.Length];
for (int i = 0; i < explodedObjects.Length; i++)
{
Guid addedObjectID;
if (explodedObjects[i].ObjectType != ObjectType.InstanceReference)
{
addedObjectID = doc.Objects.Add(explodedObjects[i].Geometry, explodedObjects[i].Attributes);
}
else
{
addedObjectID = doc.Objects.AddInstanceObject(((InstanceObject)explodedObjects[i]).InstanceDefinition.Index, ((InstanceObject)explodedObjects[i]).InstanceXform);
}
var addedObject = doc.Objects.Find(addedObjectID);
addedObject.Geometry.Transform(transformOfExplodedObjects[i]);
addedObject.CommitChanges();
IDs[i] = addedObjectID;
}
doc.Views.Redraw();
return Result.Success;
I can provide the files as well…
Posts: 2
Participants: 1
Read full topic
↧
October 8, 2018, 11:57 pm
@D-W wrote:
I need to reference my *.rhp file but VS is saying that file cannot be added - if i rename it to *.dll it works fine - is there any workaround for this?
If i try to reference it from c++/cli vs isn’t complaining but during runtime it tells that file doesn’t exists - unless i’ll rename file to *.dll … For rhp i get exacly this:
Exception not handled: System.IO.FileNotFoundException:
@dale @stevebaer @pascal
Posts: 5
Participants: 2
Read full topic
↧
↧
@samlochner wrote:
Say I have a polysurface I intend to be water tight, but it has some naked edges I can see via “ShowEdges”.
Manually, I’m able to choose adjacent pairs with “JoinEdges” and, after doing this for a few edges, it’s sealed up.
I’m wondering how I can do this programatically with rhinocommon for a given polysurface with naked edges.
Any suggestions?
Thanks,
Sam
Posts: 1
Participants: 1
Read full topic
↧
October 10, 2018, 7:56 am
@Petras_Vestartas wrote:
Hi,
In Rhino Plugin C++ I just want to retrieve two curves by separate commands.
I simply write the code below, but when I run it only first curve is selected but not a second command is not executed (neither I can select second curve nor I see the text “Select second curve”).
What I am missing?
In command line I see only Select first curve and no text Select second curve
What I write below as code is not right…
CRhinoGetObject gc0;
gc0.SetCommandPrompt(L"Select first curve");
gc0.SetGeometryFilter(CRhinoGetObject::closed_curve);
gc0.GetObjects(1, 1);
if (gc0.CommandResult() != success)
return gc0.CommandResult();
const CRhinoObjRef& obj_ref0 = gc0.Object(0);
const ON_Curve* crv0 = obj_ref0.Curve();
if (crv0 == 0)
return failure;
CRhinoGetObject gc1;
gc1.SetCommandPrompt(L"Select second curve");
gc1.SetGeometryFilter(CRhinoGetObject::closed_curve);
gc1.GetObjects(1, 1);
if (gc1.CommandResult() != success)
return gc1.CommandResult();
const CRhinoObjRef& obj_ref1 = gc1.Object(0);
const ON_Curve* crv1 = obj_ref1.Curve();
if (crv1 == 0)
return failure;
More simply can someone give an example how to retrieve two curves in separate commands?
Posts: 5
Participants: 2
Read full topic
↧
October 10, 2018, 9:26 am
@lucabrasi wrote:
Hi,
Is there a way to show and get the value of this dialog? I want to simulate like drop file!
![Fiel%20Options]()
Thanks,
Luca
Posts: 1
Participants: 1
Read full topic
↧
↧
October 11, 2018, 6:54 am
@Willem wrote:
Hi,
I’m puzzled by the tolerance setting for Curve.IsArc()
A curve that test True for Curve.IsArc()
but False for Curve.IsArc(0.1)
I would expect any tolerance to return True if a zero tolerance is True
Do I lack some fundamental knowledge on what this tolerance means or is this buggy behaviour?
find the curve in this file:
ToArc_or_not_ToArc.3dm (22.3 KB)
import rhinoscriptsyntax as rs
import scriptcontext as sc
def find_arc():
objs = rs.NormalObjects()
for id in rs.NormalObjects():
curve = rs.coercecurve(id)
if curve:
print 'arc at tol:zero == {}'.format(curve.IsArc() )
print 'arc at tol:0.1 == {}' .format(curve.IsArc(0.1))
find_arc()
printout:
arc at tol:zero == True
arc at tol:0.1 == False
Thanks
-Willem
Posts: 1
Participants: 1
Read full topic
↧
October 12, 2018, 8:00 am
@dave_stasiuk wrote:
We are working with some large point clouds and have had great success in using RTrees for rapid traversal and analysis. However, there is a obviously a large expense in the initial generation of the RTree, and if we could do it once for each cloud, it would save a lot of time. Does anyone have any recommendations for serializing RTrees for future use?
Posts: 3
Participants: 2
Read full topic
↧
October 13, 2018, 9:33 am
@mikhail wrote:
Is there a way to nuke all the keys all at once on a specific GUID using Python?
I know you can do it one at a time, but I don’t want to have to specify every key manually. I want to just feed the object ID into it and have a clean slate coming out.
Thanks in advance!
Posts: 1
Participants: 1
Read full topic
↧
October 14, 2018, 10:18 am
@SpunkyDeadcat wrote:
Is there a quicker way to get a plane from a instance reference than…
var blockRef = block.getRefrences(0);
var xform = blockRef.InstanceXform;
Plane blockPlane = Plane.WorldXY.Transform(xform);
Posts: 1
Participants: 1
Read full topic
↧
↧
October 14, 2018, 5:08 pm
@samlochner wrote:
Hi,
I have a brep with just one surface that is trimmed. I would like to update the brep such that the surface’s x and y directions are inverted and swapped while still maintaining the trims. I’ve tried to figure it out myself but run into various road blocks, like the trims of a brep be readonly etc. I’m hoping someone could provide me some code to update a brep this way (using rhinocommon).
Thanks,
Sam
Posts: 1
Participants: 1
Read full topic
↧
October 15, 2018, 9:29 am
@gennaro wrote:
Hi everybody,
I am trying to transform an object through a CRhinoDoc::TransformObject call with AddTransformHistory set true, as some descendants in the history depends on this object. I would like to know how to force the history update to the descendants.
Thanks,
G.
Posts: 1
Participants: 1
Read full topic
↧
October 15, 2018, 2:45 pm
@mikhail wrote:
I have a group with 3 polysurfaces objects and 1 text dot.
I have let’s say like 20 groups that are like that.
After make2D runs the initial grouping gets lost, best it can do it give you 3 groups with “1” object in each, it will no longer have all 4 objects grouped up as previously?
Is there any workaround where I can still retain the original grouping?
Maybe there is a way to run make2d inside of python with extra functionality?
I need it working on windows rhino6.
Posts: 3
Participants: 2
Read full topic
↧
October 16, 2018, 12:15 am
@Noos wrote:
Hi all.
I’m starting to write a plugin again with RhinoCommon and C#. Last time I did it with Rhino 4.
I am finding many improvements.
A silly question perhaps.
I haven’t found specific examples on how to set the plugin info.
Those that show Rhinoceros in the plugin properties dialog.
In version 4 there was a PlugInVersion() method, in 5 and 6 it seems to be a readonly property…
Posts: 2
Participants: 2
Read full topic
↧
↧
October 16, 2018, 2:40 am
↧
October 17, 2018, 1:20 am
↧
October 17, 2018, 9:15 am
@juergen.holl wrote:
Hi,
With the code below I want to cut a line (defined by 2 points in the xy plane) with the 2d curves of the BrepTrims of a BrepLoop. At the 2nd call of CurveLine(…) the program freezes. The Brep I use is a very simple one (see attached file). Does anyone have an idea?
I use Rhino 6 with RhinoCommonSimpleSurface.3dm (23.6 KB)
Regards
Jürgen
double intersection_tolerance = 0.001;
double overlap_tolerance = 0.0;
Line line = new Line(new Point3d(-5, 8, 0), new Point3d(10, 1, 0));
doc.Objects.AddLine(line);
for (int i = 0; i < brep.Faces.Count; i++)
{
BrepFace bf = brep.Faces[i];
Rhino.Geometry.Collections.BrepLoopList bll = bf.Loops;
for (int j = 0; j < bll.Count; j++)
{
BrepLoop bl = bll[j];
Rhino.Geometry.Collections.BrepTrimList btl = bl.Trims;
for (int k = 0; k < btl.Count; k++)
{
BrepTrim bt = btl[k];
Curve curve = bt.TrimCurve;
doc.Objects.AddCurve(curve);
var events = Rhino.Geometry.Intersect.Intersection.CurveLine(curve, line, intersection_tolerance, overlap_tolerance);
// Process the results
if (events != null)
{
for (int m = 0; m < events.Count; m++)
{
var ccx_event = events[m];
doc.Objects.AddPoint(ccx_event.PointA);
if (ccx_event.PointA.DistanceTo(ccx_event.PointB) > 1E-6)
{
doc.Objects.AddPoint(ccx_event.PointB);
}
}
}
}
}
}
doc.Views.Redraw();
Posts: 2
Participants: 2
Read full topic
↧
October 17, 2018, 9:47 am
@D-W wrote:
I don’t know why this is happening. When i try to use __declspec(dllexport)
all functions are crashing rhino but things which are set with extern "C" __declspec(dllexport)
in front are working ok.
@dale would you mind give me a hint why this is happening? I made a simple set without and with (extern “C”) i don’t understand why i cannot use ‘normal’ ones.
For being precise i’m calling the library from the code.
Posts: 4
Participants: 2
Read full topic
↧
↧
October 17, 2018, 11:25 am
@ricardo.eira wrote:
I’m trying to start with visual studio, especially I prefer VB, I have some basic notion so it will be easier for me to achieve the objective.
I’m trying something very easy like drawing a rectangle, something I can do with Python very easily and only with 3 lines of code
I can not find the logic, it seems very complicated, maybe it’s just the initial impression.
The question is, Is there an easy-to-understand manual?
Maybe my problem has been to start with python.
Posts: 2
Participants: 2
Read full topic
↧
October 18, 2018, 6:15 am
@bushdylanj wrote:
Let me preface this by saying that I am an absolute novice with C#.
I’m trying to make a command that, no matter what the starting viewport, will run a “meshoutline” command from the top view, and upon completing the outline, return the user to the active view that they started with, leaving all viewports intact (i.e. creating a named view of the original view and switching to that view after the ‘outline’ didn’t work because it took the place of the top view, rather than changing the active viewport.)
The reason I’m trying to do this in C# rather than a simple macro or rhinoscript is that this command will be one of a growing library of custom tools in my office for which we need a degree of version control that we haven’t figured out a system for with macros or rhinoscripts (will be making a post about that question soon)
Any ideas?
Thanks
using System;
using System.Collections.Generic;
using System.Linq;
using Rhino;
using Rhino.Commands;
using Rhino.Display;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
namespace V3PROJECT
{
public class OutlineToCplane : Command
{
public OutlineToCplane()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static OutlineToCplane Instance
{
get; private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "OutlineToCplane"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
//Meshoutline
void AcceptString(bool v)
{ AcceptString(true); }
GetObject go = new GetObject();
go.SetCommandPrompt("Type 'SelValue' or Select surfaces, polysurfaces, or meshes");
go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh;
go.GroupSelect = true;
go.SubObjectSelect = false;
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
List<Mesh> InMeshes = new List<Mesh>(go.ObjectCount);
List<RhinoObject> InMeshObjects = new List<RhinoObject>(go.ObjectCount);
List<RhinoObject> InObjects = new List<RhinoObject>(go.ObjectCount);
for (int i = 0; i < go.ObjectCount; i++)
{
ObjRef objRef = go.Object(i);
Mesh mesh = objRef.Mesh();
if (null == mesh)
InObjects.Add(objRef.Object());
else
{
InMeshes.Add(mesh);
InMeshObjects.Add(objRef.Object());
}
}
ObjRef[] meshRefs = null;
if (InObjects.Count > 0)
{
meshRefs = RhinoObject.GetRenderMeshes(InObjects, true, false);
if (null != meshRefs)
{
for (int i = 0; i < meshRefs.Length; i++)
{
Mesh mesh = meshRefs[i].Mesh();
if (null != mesh)
InMeshes.Add(mesh);
}
}
}
RhinoView view = null;
view = doc.Views.Find("Top", false); // en
if (null == view)
if (null == view)
{
RhinoApp.WriteLine("Unable to find Top viewport.");
return Result.Nothing;
}
doc.Views.ActiveView = view;
RhinoViewport vp = doc.Views.ActiveView.ActiveViewport;
for (int i = 0; i < InMeshes.Count; i++)
{
Polyline[] plines = InMeshes[i].GetOutlines(vp);
if (null != plines)
{
for (int j = 0; j < plines.Length; j++)
{
Rhino.Geometry.PolylineCurve plineCrv = new PolylineCurve(plines[j]);
plineCrv.RemoveShortSegments(RhinoMath.SqrtEpsilon);
if (plineCrv.IsValid)
{
Guid objId = doc.Objects.AddCurve(plineCrv);
RhinoObject obj = doc.Objects.Find(objId);
if (null != obj)
obj.Select(true);
}
}
}
}
for (int i = 0; i < InObjects.Count; i++)
InObjects[i].Select(false);
for (int i = 0; i < InMeshObjects.Count; i++)
InMeshObjects[i].Select(false);
doc.Views.Redraw();
return Result.Success;
}
}
}
Posts: 1
Participants: 1
Read full topic
↧
October 18, 2018, 1:22 pm
@inetbob wrote:
Is there a way to get ConstrainNormal=Yes behavior when using CRhinoSporphSpaceMorph in the c++ SDK ?
I see there is a m_N1 member to use alternatively to the target surface normal, but I’m unsure that’s it’s purpose or how I would set it to mimic the flow behavior like the Rhino app.
Posts: 1
Participants: 1
Read full topic
↧