@aitorleceta wrote:
hi,
is there an event in Rhinocommon which raises when Doc.Views.ActiveView is changed by the user?thanks
Posts: 2
Participants: 2
@aitorleceta wrote:
hi,
is there an event in Rhinocommon which raises when Doc.Views.ActiveView is changed by the user?thanks
Posts: 2
Participants: 2
@arendvw wrote:
The rhinocommon github repository has been quite helpful for me,
Are there any plans to update the source code? Or is it an experiment that is discontinued with Rhino 6?
Posts: 3
Participants: 2
@andheum wrote:
This appears to be a problem in both Rhino 5 and 6 - Attributes-Attached User Text is missing - this same data is present in the InstanceDefinition.Objects() Attributes properties.
To reproduce, make a box, assign it attributes user text, make it into a block, and run the following C# script in grasshopper:
private void RunScript(object x, object y, ref object A, ref object B) { Rhino.DocObjects.InstanceObject block = RhinoDocument.Objects.OfType<Rhino.DocObjects.InstanceObject>().First(); RhinoObject[] objs; ObjectAttributes[] atts; Transform[] xforms; block.Explode(true, out objs, out atts, out xforms); A = atts.SelectMany(a => a.GetUserStrings().AllKeys); B = block.InstanceDefinition.GetObjects().SelectMany(o => o.Attributes.GetUserStrings().AllKeys); }
You’ll see that the A output is empty, while the B output has the specified user string keys.
Posts: 1
Participants: 1
@santi.canorestrepo wrote:
Hi all,
I am having troubles trying to convert one script from python to c#. I realized that I have to change all of the structure. The code is about units. I would like to have one tool that notify me which units I am using in Rhino. here there are the scripts that I made. Also, I would like to know what the syntax for units in rhino is.
and here is the python script that I want to achieve in c#
thanks in advance for your help.
Posts: 1
Participants: 1
@UtsMicke wrote:
Rhino 6 Plug-ins
I use function “doc.Objects.AddText (sText, Plane, Height, Font, False, False)”
when I import and assign Plane a value“Dim Plane As Rhino.Geometry.Plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane ()”
I get the result {Origin = 0.0.0 XAxis = 1.0.0, YAxis = 0.1.0, ZAxis = 0.0,1}
everything works well
but if I open, I get this result ‘doc.Views.ActiveView.ActiveViewport.ConstructionPlane ()’ threw an exception of type ‘System.NullReferenceException’
and the program stops
//Michael
Posts: 2
Participants: 2
@Dmitriy wrote:
Hi,
I am using
GetObjectList
to collect Rhino Objects withObjectEnumeratorSettings
.
I need to collect objects with few names.
Currently I am usingNameFilter
property for passing one name I am looking for.
That means the following: if i have 10 names to look - I need to runGetObjectList
10 times.Is it possible to add option to use array of names for
NameFilter
property, so that GetObjectList is executed only once?Thanks,
Dmitriy
Posts: 2
Participants: 2
@onrender wrote:
Hi there,
I would like to create user interface for some scripts and I started studying the samples
When I created a new Rhino 5 plugin project I have removed all the code and replaced with the code below (same as the last code on the sample page),
using System; using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using System.Threading; using System.Windows; using System.Windows.Controls; namespace examples_cs { [System.Runtime.InteropServices.Guid("E4A93905-6E61-43BB-9FF0-4D5F6AF76704")] public class ChangeUiFromDifferentThreadCommand : Command { public override string EnglishName { get { return "csChangeUIFromDifferentThread"; } } private RhinoDoc _doc; private Label _label; private Window _window; protected override Result RunCommand(RhinoDoc doc, RunMode mode) { _doc = doc; _window = new Window {Title = "Object ID and Thread ID", Width = 500, Height = 75}; _label = new Label(); _window.Content = _label; new System.Windows.Interop.WindowInteropHelper(_window).Owner = Rhino.RhinoApp.MainWindowHandle(); _window.Show(); // register the rhinoObjectAdded method with the AddRhinoObject event RhinoDoc.AddRhinoObject += RhinoObjectAdded; // add a sphere from the main UI thread. All is good AddSphere(new Point3d(0,0,0)); // add a sphere from a secondary thread. Not good: the rhinoObjectAdded method // doesn't work well when called from another thread var addSphereDelegate = new Action<Point3d>(AddSphere); addSphereDelegate.BeginInvoke(new Point3d(0, 10, 0), null, null); // handle the AddRhinoObject event with rhinoObjectAddedSafe which is // desgined to work no matter which thread the call is comming from. RhinoDoc.AddRhinoObject -= RhinoObjectAdded; RhinoDoc.AddRhinoObject += RhinoObjectAddedSafe; // try again adding a sphere from a secondary thread. All is good! addSphereDelegate.BeginInvoke(new Point3d(0, 20, 0), null, null); doc.Views.Redraw(); return Result.Success; } private void AddSphere(Point3d center) { _doc.Objects.AddSphere(new Sphere(center, 3)); } private void RhinoObjectAdded(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); try { // when a sphere is added from a secondary thread this line will // throw an exception because UI controls can only be accessed from // the main UI thread _label.Content = message; } catch (InvalidOperationException ioe) {RhinoApp.WriteLine(ioe.Message);} } private void RhinoObjectAddedSafe(Object sender, RhinoObjectEventArgs e) { var message = String.Format("thread id = {0}, obj id = {1}", Thread.CurrentThread.ManagedThreadId, e.ObjectId.ToString()); RhinoApp.WriteLine(message); // checks if the calling thread is the thread the dispatcher is associated with. // In other words, checks if the calling thread is the UI thread if (_label.Dispatcher.CheckAccess()) // if we're on the UI thread then just update the component _label.Content = message; else { // invoke the setLabelTextDelegate on the thread the dispatcher is associated with, i.e., the UI thread var setLabelTextDelegate = new Action<string>(txt => _label.Content = txt); _label.Dispatcher.BeginInvoke(setLabelTextDelegate, new String[] { message }); } } } }
At the end I received some error message but no idea.
Is there any difference in the template that we have to modify if we want to develop a Windows Form App? I know we need to add the line
using System.Windows.Forms;
.
Posts: 2
Participants: 2
@onrender wrote:
Rhino 6 python editor is freezing when I want to open any of the method category.
I use the latest build (6.2.18065.11031, 06/03/2018), Win 8.1
Posts: 2
Participants: 2
@lungenstrudel wrote:
Hi, i am trying to create some simple linear dimensions using a pair of points for the ends (ext1, ext2) and one point (pt) in order to define the location of the dimension line.
The first dimensioin looks good, however, translating these points and recreating linear dimensions with them gives me the following result:
I don’t think this is what’s supposed to happen… Image may be NSFW.
Clik here to view.Here’s my code:
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Point2d ext1 = new Point2d(0, 0); Point2d ext2 = new Point2d(3000, 0); Point2d pt = new Point2d(1500, -100); AddLinearDimension(Plane.WorldXY, ext1, ext2, pt, doc); Vector3d translationVector = Plane.WorldXY.YAxis * -1 * 200; ext1.Transform(Transform.Translation(translationVector)); ext2.Transform(Transform.Translation(translationVector)); pt.Transform(Transform.Translation(translationVector)); AddLinearDimension(Plane.WorldXY, ext1, ext2, pt, doc); ext1.Transform(Transform.Translation(translationVector)); ext2.Transform(Transform.Translation(translationVector)); pt.Transform(Transform.Translation(translationVector)); AddLinearDimension(Plane.WorldXY, ext1, ext2, pt, doc); doc.Views.Redraw(); return Result.Success; } private void AddLinearDimension(Plane p, Point2d ext1, Point2d ext2, Point2d pt, RhinoDoc doc) { doc.Objects.AddTextDot(new TextDot("ext1", new Point3d(ext1.X, ext1.Y, 0))); doc.Objects.AddTextDot(new TextDot("ext2", new Point3d(ext2.X, ext2.Y, 0))); doc.Objects.AddTextDot(new TextDot("pt", new Point3d(pt.X, pt.Y, 0))); Rhino.Geometry.LinearDimension ld = new LinearDimension(Plane.WorldXY, ext1, ext2, pt); ld.TextHeight = 35; ld.ArrowSize = 30; doc.Objects.AddLinearDimension(ld); }
Posts: 1
Participants: 1
@rnjthmhnkl wrote:
I am trying to create breps with NurbsSurfaces with data (exported) from another modeling application. I tried, creating the brep from scratch but it proved very difficult to create a valid brep from raw data. But if I try using built in methods for creating and trimming breps, I am getting validity issues like following:
strong text
"cv[0*cv_stride + 1] = -1.#IND is not valid.\nON_NurbsCurve.m_cv[] is not valid.\nON_Brep.m_C3[0] is invalid."
What’s even stranger is that this issue is not consistent, roughly every 1 out of ten attempts the same code produces a valid brep, with the same raw data ! If I try to put a break point and step through the code, it creates an invalid brep, then I move the execution point to an earlier line of code and run the brep creation line again, it creates a valid brep.
Can anyone explain to me what I am doing wrong? How can I reliably create a brep from raw data of surfaces and trimming curves? Any help is appreciated, thank you very much!
Posts: 2
Participants: 2
@AndersDeleuran wrote:
Hi All,
I’m attempting to implement the Box.Contains(Box) method to check for coincident boxes. The API states that this method will return:
true if the box is on the inside of or coincident with this Box.
I might be misunderstanding what exactly is meant by coincident here, but am getting a
False
for cases like the left one here (I did try out a bunch of higher/lower Rhino document tolerances with the same result):
180404_BoxBoxContainment_00.gh (6.0 KB)Is this the expected behavior?
Best,
Anders
Posts: 13
Participants: 3
@Petras_Vestartas wrote:
What would be the simplest method to iterate over two equal length GH_Structure<GH_Curve> collections
For now I am iterating through ech collections like this, but I would like to know how to iterate through both of them within one and the same loop:
foreach (GH_Curve ghc in c0.AllData(true)) { ghc.Value.TryGetPolyline(out Polyline p); polys0.Add(p); } foreach (GH_Curve ghc in c1.AllData(true)) { ghc.Value.TryGetPolyline(out Polyline p); polys1.Add(p); }
Posts: 6
Participants: 3
@Simon_Weinberger wrote:
Hi there,
Attached is a file created with Rhino 5. Just a simple box with the default stripe material applied. ApplyUvwTransform returns false, but the UvwTransform seems to be used in the viewport. It returns true after I change the values.
I have noticed that the same file works OK when opened with Rhino 6. Can you confirm that the bug is fixed in Rhino 6? And what about any possible updates for Rhino 5?
Thanks,
Simon Weinberger
Posts: 2
Participants: 1
@Ignacio wrote:
Hi!
Im updating my digitizer plugin for rhino 5, to work with rhino 6.
Im using the template of RhinoCommon for Windows of the DigitizerPlugin, i can load the and connect to the digitizer plugin perfectly to rhino 6, but my problem is the next:After disconnecting the digitizer plugin, i can no longer to reconnect to the plugin digitizer and the rhino console shows me the next message “Unable to connect to the digitizer.”
Im using the template of the DigitizerPlugin for RhinoCommon v6. and adding/changing the next code
protected override bool EnableDigitizer(bool enable) { // if the plugin was enabled then return true to start the digitizer calibration // when the user wants disconnect the digitizer, then the calibration is not necessary return enable; } protected override UnitSystem DigitizerUnitSystem { get { return UnitSystem.Millimeters; } } protected override double PointTolerance { get { return 0.01; } }
all this using _Digitize and _DigDisconnect commands respectively, and the digitizer toolbar.
thanks!
Posts: 3
Participants: 2
@alonso.rosado wrote:
Hello there!
Im sorry if the title is is a bit convoluted, and somewhat long.
Im marking the actual questions per se in bold, though I think their context is necessary.
I’ve been messing around with the rendermaterials and been trying for them to generate some custom info, in an external container, that was supposed to be deleted when the material is deleted from the scene. For that I overloaded the Dispose function to delete the external info from its container.
When I saw that the data were not deleting properly, I proceeded to debug and discovered a couple of things. First, there is a lot of calls being done to my custom RenderMaterial even if its not present in the scene, and this is messing somewhat with my external data by adding extra unnecessary instances. Why is the RenderMaterial constructor being called up to six times to generate a single render material?
This gets cleand up eventually when the corresponding dispose functions get called, but in certain cases (due to code on my side) it leads to undeleted info.
The trouble comes when, even it the material is deleted successfully from the material list on the UI, my data don’t dissapear properly.
I imagine the material might not be deleted for Undo/redo purposes, but if that is so, how would you suggest me getting my data deleted? I can manage the undo/redo on my side, but I’m somewhat confused on how would I get the proper events to signal me to do so and why the materials are created so many times.
Thanks in advance
Posts: 2
Participants: 2
@lukeniwranski wrote:
Hello,
What is the recommended method for finding memory leaks in a C++ plug-in written for Rhino 6?
Please correct me if I’m wrong, but for Rhino 4 and Rhino 5, the SDK provided a copy of Rhino_d.exe that was linked with the debug CRT library. But from what I can tell, Rhino 6 doesn’t do this. The manual migration guide indicates to delete the old Debug configuration and just use the PseudoDebug configuration instead (which uses the non-debug CRT library). Because Rhino now uses the non-debug CRT, all C++ plug-ins must now also use the non-debug CRT.
How can we detect memory leaks without the debug CRT and it’s suite of debug allocation/deallocation tools? Is there a workaround or alternative to this? Are there any plans to re-introduce a copy of Rhino_d.exe with the C++ SDK to allow for linking with the debug CRT?
Thanks,
-Luke
Posts: 1
Participants: 1
@andy.marshall wrote:
Hello,
I develop Rhino plug ins in C# using RhinoCommon and have noticed that the Status Bar Update (
StatusBar.UpdateProgressMeter(1, false); ) is holding up my threads in Rhino 6. HOWEVER, this was not the case in Rhino 5.Is it possible that this command is no longer thread safe in Rhino 6? If not could this be fixed?
Thanks,
Andy
Posts: 2
Participants: 2
@HepChan wrote:
Hi @dale,
I would like to print a Pdf output of the layout pages creating them quietly.
This is the sample code used SamplePrintPdf.cs (3.1 KB)
Only the first page is displayed SampleOutput.pdf (62.4 KB)
What is the error in the code?
Posts: 1
Participants: 1
@tom.norris23 wrote:
Any one know where I can find a list of the children of scriptcontext.doc.RenderMaterials:
I have “bitmap-texture” for the color bitmap
but would also like to get the transparency and bump maps?
Thanks
Tom
Posts: 7
Participants: 2
@clement wrote:
Hi @dale, @stevebaer,
i have a custom conduit using
DisplayPipeline.Draw2dText
method in thePostDrawObjects
event. In V5 it works, but in V6 nothing is drawn. I use this one which allows to pass aPoint3d
. Tries various overloads but none of them work in V6, if i draw inDrawForeground
it works.
_
c.
Posts: 1
Participants: 1