Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all 8529 articles
Browse latest View live

Exporting geometry to file

$
0
0

@rgr wrote:

I want to write a single Brep to a .3dm file. The brep is not added to a document. However, I get a “‘f.Created’ threw an exception of type ‘System.ArgumentOutOfRangeException’” error even before I add the Brep. The Brep itself is valid.

        Rhino.FileIO.File3dm f = new Rhino.FileIO.File3dm();
        f.Objects.AddBrep(FinalBrep);
        bool writeResult = f.Write(FilePath, 0);
        f.Dispose();

Excuse the german system language, basicly saying “Year/Month/Day DateTime not representable” and “Argument out of bounds” but how could I change that, if that’s the issue?

edit: obviously “writeResult” is false.

Posts: 2

Participants: 1

Read full topic


Filter commands

RhinoScript vs SendKeystrokes

$
0
0

@kitjmv wrote:

Hello,

I built a plugin based on voice recognition.
For a reasons that i ignore.

If I use RhinoApp.RunScript for starting a new command, I can not execute a second command with ‘RunScript’ or ‘SendKeystrokes’ (like ! _Box or just ! for cancel if I say “Cancel”).

If I use RhinoApp.SendKeystrokes for starting a new command, I can run the second command but SendKeystrokes unselect all object before send the string.

All tests without the speech recognizer work exept SendKeystrokes that are invariant (it unselect all object before send the string).

I assume that RunScript creates a new thread and not SendKeystrokes. I have good ?

To clarify the reaction between RunScript and SendKeystrokes in my plugin :

I say RhinoApp Then I say RhinoApp result
“Union boolean” RunScript("! _BooleanUnion", true) “Cancel” RunScript("!", true) not work
“Union boolean” RunScript("! _BooleanUnion", true) “Cancel” SendKeystrokes("!", true) not work
“Union boolean” SendKeystrokes("! _BooleanUnion", true) Unselect all previous objects “Cancel” RunScript("!", true) work
“Union boolean” SendKeystrokes("! _BooleanUnion", true) Unselect all previous objects “Cancel” SendKeystrokes("!", true) work

Have an idea why it works like this?

How can I prevent SendKeystrokes from deselecting all objects before sending the string?

Thank you,
jmv

(note: of course, I placed a RhinoApp.Wait before executing a command)

Posts: 1

Participants: 1

Read full topic

[Rhino6] FileImportPlugIn.ReadFile results in empty document

$
0
0

@menno wrote:

I have a strange thing here: we have multiple file import plug-ins and one of them is giving problems. I traced it to a difference in OnNewDocument and OnBeginOpenDocument events that are raised. The problematic plug-in first gets an OnBeginOpenDocument for a document with a certain runtime serial number. This document is also used in the import routines and I put all the geometry in that document, layers and all. After the import is completed, an OnNewDocument is raised where the serial number is increased by one compared to the document I got for the import.
Other file import plug-ins do NOT raise an OnNewDocument event and there the importing is successful.

@dale Any idea why this might happen? I have no clue where to start.

PS. all file import plug-ins work correctly in Rhino 5.

Posts: 1

Participants: 1

Read full topic

Rhinocommon equivalent to "_fin" command (SOLVED)

$
0
0

@Tom_ wrote:

Dear Community - or Dear Steve @stevebaer
can anybody tell me, if there is a Rhinocommon equivalent to the Rhino _fin command.
http://docs.mcneel.com/rhino/5/help/en-us/commands/fin.htm

i know there is a workarround Rhinocommon Curve.OffsetNormalToSurface Method
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_OffsetNormalToSurface.htm
and this can be combined with loft
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_CreateFromLoft.htm

thanks for a short hint / yes or no / or a better workarround
all the best - tom

Posts: 3

Participants: 2

Read full topic

How can I influence display order of Rhino objects?

$
0
0

@Peter_Salzman wrote:

Hi! For a project we definded an own Displa Mode. One objective is to enabling different display attributes for different data types (e.g. switching easily mesh edges on/on when doing reverse eng., having a different color for meshes and surfaces, switching all objects of a special data type like mesh on/off etc.). This works well in general.

We have now also different colors for edges of untrimmed surfaces compared to trimmed surfaces. Unfortunately it looks very “crissling” when we have common edges (trim edge meets an utrimmed edge with different colors). maybe later on I could send a screen shot. I thought one way to avoid this ist to influence the display order dependent on the data type. E.g. display first meshes, that trimmed surfaces and then untrimmed surfaces.

When I use the SC_DRAWOBJECTS channel in my display conduit I can handle each object, but have no influence to the order of display. Ist teher a way to do it?

Thanks.

Posts: 1

Participants: 1

Read full topic

Problem with using a modified construction plane in the plug-in

$
0
0

@resammc wrote:

Hi,

I’m trying to use a picked object to move and rotate the CPlane in Rhino, and then create a new geometry (e.g. a surface) based on the new construction plane coordinates. I successfully move the CPlane to the desired location, but when I try to add a new object (inside the plugin) to the Rhino document, it takes the World coordinate system. However, if I try to interactively add, let’s say, a point to my document, it uses the construction plane coordinate system!

So, I’m doing something like this:

  1. I ask the user to pick a circle object.

  2. then I get the origin and the plane of this circle from OpenNURBS.

  3. I get the current construction plane:
    CRhinoView* view = ::RhinoApp().ActiveView();
    if (!view)
    return CRhinoCommand::failure;

ON_3dmConstructionPlane cplane = view->Viewport().ConstructionPlane();

  1. I modify the m_plane of the construction plane
    cplane.m_plane.CreateFromNormal(New_Origin, Normal_To_The_Plane);

  2. I set the new construction plane and redraw:
    view->Viewport().SetConstructionPlane(cplane);
    view->Redraw();

at this point, I can see in the debug-mode that the construction plane has moved successfully.

  1. Then I send the radius of the circle to a function where I define a NURBS surface based on that.
    ON_NurbsSurface Base_Surface = CreateTheBaseSurface(Radius);
    (I take the origin for this surface to be (0,0,0))

  2. Finally, I add the surface object to the document and redraw:
    context.m_doc.AddSurfaceObject(Base_Surface );
    context.m_doc.Redraw();

But, the surface pops in the World’s coordinate system.

I have tried many things, but couldn’t figure out what the problem is. Am I missing something here?

I know that I can transform my object to the place that I want, but it would be easier if the construction plane thing were working.

Any help regarding this is greatly appreciated.

P.S.: I’m writing the plug-in in C++ and Rhino 6.
P.S.2: view->Viewport().PushConstructionPlane(cplane) also doesn’t work

Posts: 1

Participants: 1

Read full topic

RhinoCommon C# Recognize ObjectType

$
0
0

@dimcic wrote:

Hi,

this is a pretty basic question, but what would be the easiest option to recognize the ObjectType? (using RhinoObject or ObjRef as input)?

I don`t see anything in the Attributes…I could check for every possible type:

var curve = gc.Object(i).Curve();
if (null != curve)
I guess I have a curve

But that seems a bit much…?

Thanks!

Posts: 2

Participants: 2

Read full topic


Adding InstanceReferences to a File3dm object

$
0
0

@rgr wrote:

Hello,

I want to add InstanceReferences to a newly created File3dm object, How can I do that?

Amongst the things I tried is adding the InstanceReferenceGeometry to the new file using

  file.Objects.AddinstanceObject(iRefGeo);

but that just created empty files, even though the InstanceReferenceGeometry itself was valid and the ObjectTable for that file is populated. Do I need to add the InstanceDefinitions? And how?
Or is there a better way?

    public void ExportBlocks(RhinoDoc doc, List<InstanceReferenceGeometry> instanceReferenceGeometries)
    {
        string path = "C:\\dummypath\\dummyfile.3dm";

        Rhino.FileIO.File3dm file = new Rhino.FileIO.File3dm();

        foreach (InstanceReferenceGeometry iRefGeo in instanceReferenceGeometries)
        {
            file.Objects.AddInstanceObject(iRefGeo);
        }

        file.Write(path, 6);
    }

Posts: 1

Participants: 1

Read full topic

How to sign Mac plugins?

Use aws-sdk c++ for s3 file upload

$
0
0

@ramadan wrote:

Hello, So i have two questions.

  1. Is it possible to use aws-sdk for c++ plugin development, because i am trying to use to upload some file into s3, but i get Access violation ... every time…
  2. I am getting same error with http-requests too, so did any of use ever did API requests with Rhino, if yes how is that done, and is this a threading error or something…
    PS: If these are possible, please led me to some sample or something, cause i cannot find anything similar…
    Thanks in advance

Posts: 3

Participants: 2

Read full topic

RhinoCommon CreateDevelopableLoft Issue

$
0
0

@LarryL wrote:

I have started working with the static Brep method, CreateDevelopableLoft. In general I have been getting good results but for some reason these particular curves are failing to generate a Brep even though the DevLoft command does so perfectly fine. I’ll attach the sample file containing the two rails and the sample command.

Posts: 2

Participants: 1

Read full topic

Problem in creating a new C++ plugin project in VS2017

$
0
0

@15951991225 wrote:

Dear Rhino developers, I am a new developer, I am learning " Creating your first C/C++ plugin for Rhino".
After my plugin is loaded, in this step “Adding Additional Commands: Rhino plugins can contain any number of commands. Commands are created by deriving a new class from CRhinoCommand. See rhinoSdkCommand.h for details on the CRhinoCommand class.” Where can I find rhinoSdkCommand.h? Do I need to create one ? Thank you very much!

Posts: 4

Participants: 2

Read full topic

Layer.SetPerViewportVisible

$
0
0

@lando.schumpich wrote:

Hello,
I tried using the Layer.SetPerViewportVisible method today, and i just can’t get it to work, is there a code sample around i can refer to?

Layer.SetPerVieportVisible(System.Guid.Empty, False) works like expected, but neither detailViewObject.Id nor detailViewObject.Viewport.Id seem to be doing anything, and no error is returned.

Would be thankful for any help,
Lando

Posts: 1

Participants: 1

Read full topic

Exporting rhino plugin as .rhi

$
0
0

@ramadan wrote:

Hello.
I’m having issues exporting rhino as single .rhi file.
If i understood correctly, the files that are generated into x64/Release i should all zip into single file, and then rename that into something.rhi. Is this correct?
I am receiving: The file appears to be corrupted...
What should i do, how do i check what im doing wrong… Isn’t there any other way to export the plugin as a single install-able file?
Btw i am doing a Modeless Dialog(MFC) plugin with c++.

Posts: 1

Participants: 1

Read full topic


AddRhinoObject raised twice when event handler references class param

$
0
0

@Jon wrote:

Apologies if this is a basic programming question. Typically when moving an object in Rhino, the AddRhinoObject event is raised once. However, if I reference a class field inside the event handler, the event is raised twice (see below). How can I prevent this from happening?

    internal class RhinoListenerClass
    {
        private Task listener;
        private List<double> data;

        internal RhinoListenerClass()
        {
            data = new List<double>();
            listener = RhinoListener();
        }

        private async Task RhinoListener()
        {
            await Task.Run(() =>
            {
                RhinoDoc.AddRhinoObject += (s, e) =>
                {
                    Eto.Forms.MessageBox.Show("AddRhinoObject");
                    var d = data; // this causes the event to be raised twice
                };
            });
        }
    }

Thanks :slight_smile:

Jon

Posts: 1

Participants: 1

Read full topic

Rhino C++ plugin question : How do I get an object's transformation attributes?

$
0
0

@alexian007 wrote:

Hi there, I am using the C++ SDK for rhino, and I want to get the attributes regarding the transformation (and translation, rotation, scale, etc) of that object.
I have been looking through the docs, but so far I have only found:
bool ON_3dmObjectAttributes::Transform ( const ON_Xform & xform )

I don’t think that this will be useful for me. So, what do I do to get the object’s transformation data?
Thanks!

Posts: 1

Participants: 1

Read full topic

Kill python script

$
0
0

@ricardo.eira wrote:

Hello,

Any command to kill the python script run?

Rhino.RhinoApp.RunScript("-_KillPythonScript (test.py) ", false); ???

Thanks

Posts: 1

Participants: 1

Read full topic

(C++) How to detect if a referenced Brep object is Trimmed after reading it from the user

$
0
0

@robin_l wrote:

Hello everyone

I’m currently writing a small script where I get some objects from the user and deform them. The way to deform them differs depending on whether the object has been trimmed previously or not, as untrimmed ones allow me some simplifications.

So, before deforming, I need to detect whether a trim was present. I do know that usually a Geometry filter is used for this purpose, but this doesn’t help me as I want to read the objects with or without trims, and that attribute doesn’t seem to be passed along to the reference or object.

Currently I have a very simple method:

bool isTrimmed(CRhinoObjRef brepref) {
	// referenced object is always a brep with a single face
	CRhinoBrepObject *obj = (CRhinoBrepObject *)brepref.Object();
	ON_Brep *brep = obj->Brep()->Duplicate();

	ON_BrepFace *face = brep->Face(0);
	ON_BrepLoop *outerLoop = face->Loop(0);

	if (
		face->LoopCount() == 1 &&  // brep has no holes
		outerLoop->TrimCount() == 4  // outer loop contains 4 edges
		) {
		return false;
	}
	return true;
}

Obviously, an object could be trimmed and still have 4 edges in the outer trimming loop, so this method is incomplete.

Is there a way to get the geometry attribute from the reference? Or, if not, how would I best detect trims in the outer loop? Or, even, in a Brep in general?

~robin

Posts: 1

Participants: 1

Read full topic

How to keep the point order

$
0
0

@hearts_j wrote:

Hi,there,I want to use a serial of points to create a curve by “CreateInterpolatedCurve”; command .If I draw point by point ,the curve is OK ,but if I move some points of them , the curve can’t not be created properly , when I checked the point’s attribute , I found that the orders of the points that I moved are changed(in the end of the point’s ID, is the order number?).how can I keep the original orders of the points?

Posts: 1

Participants: 1

Read full topic

Viewing all 8529 articles
Browse latest View live