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

Domain after join

$
0
0

I have this simple closed rectangle,

This peace of code, take curve get the domain, explode and join the curves again, once again
take the domain.

import rhinoscriptsyntax as rs
rec = rs.GetObject("Get");

domain = rs.CurveDomain(rec);
print domain[0]
print domain[1]
print ("--------------------")
explode= rs.ExplodeCurves(rec,True);
join = rs.JoinCurves(explode);
domain = rs.CurveDomain(join);
print domain[0]
print domain[1]

My question is, isn’t that supposed to return the same domain? why is it one domain and then another?

Thanks

1 post - 1 participant

Read full topic


How to "instance" RenderContent?

$
0
0

The system I am integrating is nodal, so there are various material-related nodes, which are not materials, but which may be referenced by N materials. It’s not great to have to implement these as “materials” (or textures) in Rhino, but it appears that is the only way.

However, I have not yet figured how to make “instances” of these, as we see when choosing an existing Rhino texture or material, with the “share all settings” option checked. I can get the user’s intention from the ShowContentChooser function, but haven’t been able how to figure out how to implement the “instance” result.

The docs appear to indicate that a render content can be set as the child of another at most once, and this appears to be the case, so it seems either I am overlooking some method for instancing render content, or that it is not exposed in rhcommon (the c++ rdk MakeGroupInstance seems promising?).

Experimenting, I am able to put these in the document instead of parenting them to a render content, and then store their ID in a field for later retrieval, and this would sort of work, but it clutters up the material list with these non-materials, and the items do not appear parented (in tree view) under the materials that use them, as happens with “instanced” Rhino child contents. So I’d prefer to mimic the Rhino behavior with instancing of render content.

So I’d like to know if I’m missing something, or if this is perhaps not possible via (v6) rhcommon.

1 post - 1 participant

Read full topic

Math.Net function in Python with Rhino for Mac?

Set Recently Opened Files list?

$
0
0

Hi All,

Is there a way to manually set the Recently Opened files list?
I know I can get it via: Rhino.ApplicationSettings.FileSettings.RecentlyOpenedFiles Method

But I actually would like to modify it.

The reason is I am working on a script that mass-imports external file assets either via Insert or Import commands, and after the script runs, all the Recent Files list gets populated by these imported by the script. I want the script to not affects that list. So my idea was to remember the original list via the method above, and one the script is done, restore the list. Is there a way ?

thanks,

–jarek

1 post - 1 participant

Read full topic

Programming a new geometry

$
0
0

I would like to program a new geometry. Its name would be ‘Graph’ and it represents a visible graph on the rhino viewport. Like the other rhino geometries I want it to have its own commands. In certain way it would be like a curve geometry, in which there wouldbe posible to connect more than two lines for each node.
I would like to use this geometry as reference in grasshopper, too.

So, this is my question: Where do I start from?

7 posts - 3 participants

Read full topic

Wish: option to show only certain categories/types in ShowContentChooser

$
0
0

Pretty simple, I’d like to be able to tell ShowContentChooser to show only certain types of content.

I suppose the simplest form of this would be to accept a single category name and preset that in the dialog. More powerful would be to provide overloads accepting a list of categories, and a list of content type IDs.

3 posts - 2 participants

Read full topic

Accessing Rhino from console app

$
0
0

Hi guys,

I am creating a Rhino instance via

dynamic rhinoInstance = null;
string id = "Rhino.Application";
System.Type t = System.Type.GetTypeFromProgID(id);
rhinoInstance = System.Activator.CreateInstance(t);

Is there anything useful that can be done after that? for example get access to the Rhino document and use some RhinoCommon?

For example, Excel lets you do the following:

using Excel =  Microsoft.Office.Interop.Excel;

Excel.Application objApp;
 
// Instantiate Excel and start a new workbook.
objApp = new Excel.Application();
objBooks = objApp.Workbooks;
objSheets = objBook.Worksheets;


Excel.Workbooks objBooks;
Excel.Sheets objSheets;
Excel._Worksheet objSheet;
Excel.Range range;

Reference: https://docs.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/automate-excel-using-visual-c-fill-data

Thanks

1 post - 1 participant

Read full topic

ON_Viewport::GetWorldToScreenScale pixel scaling issue in high DPI display

$
0
0

Hi,

I have an issue related to High DPI display and I don’t find a solution in the guide.

I have a getter derived from CRhinoGetPoint in which I dynamically draw a filled circle of a fixed real distance. For that I use CRhinoDisplayPipeline::DrawPoint as there’s no function to draw a filled circle from ON_Circle.
I also draw a non-filled circle of the same radius, with CRhinoDisplayPipeline::DrawCircle.
In this picture I draw the inner part in grey and the outer part in black with the same center (note, this is just an example as actually I have to draw different filled/non-filled circles with different centers but same radius):

The problem is that in High DPI displays there’s a mismatch of radius: the filled circle (whose radius is defined in pixels in the SDK) is way bigger than the non-filled circle. I’ve been reported this by a customer using a 4K monitor; unfortunately I don’t have such a monitor but I know there’s a problem there.

Please take a look on how to fix this, here’s the sample:
cmdSampleGetPointPixelCircle.cpp (2.7 KB)
The getter:

class GetPointPixelCircle : public CRhinoGetPoint
{
public:
	GetPointPixelCircle(double circleRadius);
	void DynamicDraw(CRhinoDisplayPipeline& dp, const ON_3dPoint& pt);
private:
	double m_circleRadius;
	ON_Color m_innerColor, m_outerColor;
	int m_thickness;
};

GetPointPixelCircle::GetPointPixelCircle(double circleRadius)
{
	m_circleRadius = circleRadius;
	m_innerColor = ON_Color::Gray230;
	m_outerColor = ON_Color::Black;
	m_thickness = 10;
}

void GetPointPixelCircle::DynamicDraw(CRhinoDisplayPipeline& dp, const ON_3dPoint& pt)
{
	int circlePixelRadius;
	const CRhinoViewport* vp = dp.GetRhinoVP();
	if (nullptr != vp) 
	{
		double pixelsPerUnit = 0.0;
		if (vp->View().m_vp.GetWorldToScreenScale(vp->View().TargetPoint(), &pixelsPerUnit)) 
		{
			// Draw inner part
			circlePixelRadius = (int)(m_circleRadius * pixelsPerUnit);
			dp.DrawPoint(pt, circlePixelRadius, ERhinoPointStyle::RPS_CIRCLE, m_innerColor);

			// Draw outer part
			const ON_Plane& plane = vp->ConstructionPlane().m_plane;
			ON_Circle circle(plane, pt, m_circleRadius);
			dp.DrawCircle(circle, m_outerColor, m_thickness);
		}
	}

	CRhinoGetPoint::DynamicDraw(dp, pt);
}

I think the issue is about the conversion of the real radius to screen pixel radius through ON_Viewport::GetWorldToScreenScale. I took that part of code from @dale’s SampleMarker.

Thank you,
Pablo

1 post - 1 participant

Read full topic


The plug-in does not appear to be compatible with this version of Rhino Custom Plugin

$
0
0

I have been writing a custom plugin for work and everything has been going well for Geometry Generation and otherwise. However it’s gotten to the point we need to create some UIs using XAML. I have taken the SampleCsWpf project from the RhinoCommon GitHub samples and basically copy pasted it into my project and refactored it somewhat. The separate project works well and the panel appears. But when I copy it into my project line by line and fix any tiny errors I get this message:

Unable to load .rhp plug-in.
The plug-in does not appear to be compatible with this version of Rhino

This is true for Rhino 6 and 7 WIP. And I have had this problem consistently whenever trying to factor XAML into a panel in my project, any slight addition seems to cause strange incompatibility issues. I’m not sure exactly what code to post, so please ask for anything necessary. Obviously I can’t post the whole project as it’s for my company.

1 post - 1 participant

Read full topic

Fnd the X,Y coordinate of a point seen in a top down view in the model space relative to a layout

$
0
0

How can I find the X,Y coordinate of a point seen in a top down view in the model space relative to a layout and its viewport so that I can place the Dimension in layout space.

I have tried referencing the geometry whilst the layout view is active and acquiring evaluated points from its bounding box but that doesn’t seem to work.

2 posts - 1 participant

Read full topic

Custom Layer Properties?

$
0
0

Hi all,
I’m working on a plugin to do some architectural analysis, and I’d like to add another “base” property (like color, material, linetype - which on each object are either set by the object or inherited from the layer) to all items in the document. To control it I’d like to add another column to the layer panel:

image

It should also be possible to change this on a per-object basis as you can with color, material, etc, in the properties panel :

.
I suppose it really becomes an additional button/object properties page (like “Material”, “Decal”, etc.) - I’ve seen the SampleCsWinForms with the example. So, can those object attributes be controlled on a per-layer basis, from the Layer panel?

Is this possible, or should it be a new “Material” type?
Thanks
Dan

1 post - 1 participant

Read full topic

Rhirno.geometry vector 2d?

$
0
0

rhirno.geometry vector 2d ?

processing -> rhino.geometry

a = random.uniform(0,1)
dir = rg.Vector2d.Zero
dir.X = cos(a)
dir.Y=sin(a)
i want to change the value of the dir.X.

is it possible?

print(dir) -----> (cos(a),sin(a))

2 posts - 2 participants

Read full topic

CommitChanges returns false. How to debug?

$
0
0

Here is a snippet of my code going through a list of ObjRefs and trying to change object color

// selected is an array of ObjRef
foreach (int i in ri)
{
    selected[i].Object().Attributes.ColorSource = ObjectColorSource.ColorFromObject;
    selected[i].Object().Attributes.ObjectColor = colorDialog1.Color;
    if (!selected[i].Object().CommitChanges()) MessageBox.Show("didn't happen");
}

How would I debug when that CommitChanges() call returns false? BTW no exception thrown at all…

A bit more background is that the variable “selected” is an ObjRef[] assigned to a class variable of a winforms UserControl. “ri” is just a list of int. I click a button and it calls up a winforms ColorDialog. if result is ok, assign that color to all these objects.

1 post - 1 participant

Read full topic

(rhino python script) ------> grasshopper

$
0
0

(topic withdrawn by author, will be automatically deleted in 24 hours unless flagged)

1 post - 1 participant

Read full topic

Done-installing-plug-ins-press-close-to-continue-but-error-loading c# plugin

$
0
0

I have one installer error-done-installing-plug-ins-press-close-to-continue-but-error-loading
I have dotnet framework 4.5 and when I uninstalled previous version manually by going to C:\Program Files\Common Files\McNeel\Rhinoceros\6.0\Plug-ins and removing the plugin and again installing it via rhi installer it installed but gave this error.

2 posts - 1 participant

Read full topic


Eto DynamicLayout Size Before Initialization

$
0
0

My tests are based on SampleEtoCollapsibleDialog.py in

I was writing my own form when I saw that collapsible sample and realized that it is not working.
It crashes cause the size of an invisible layout seems to be unknown until it is visible.
Then, when the button event tries to add hidden layout size to visible size, values are wrong.
in:

self.ClientSize = drawing.Size(max(self.ClientSize.Width, self.collapsePanel.Width), self.ClientSize.Height + self.collapsePanel.Height)

The first time the button event is triggered self.collapsePanel.Height equates 0.

I tried to collapse it at start and it isn’t really neat visually and programmatically.

So, if I want to start a dialog with a hidden part …
Is there a way to pre-calculate size of layout without showing it ?

regardsSampleEtoCollapsibleDialog.py (5.6 KB)

1 post - 1 participant

Read full topic

RhinoDoc.WriteFile and IO related stuff

$
0
0

Hi. Never know who to pin to this kind of topic @pascal @dale @stevebaer ? I’d like to talk about this method as its behavior is different than description besides gives different results than usually expected.

At first glance description of it currently is wrong as it does NOT change the current document to saved document while -> https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_RhinoDoc_WriteFile.htm says that “Note, the active document’s name will be changed to that of the path provided” i guess its time to fix the description of it.

Now to the business why this command when providing WriteSelectedObjectsOnly=true with -> https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_FileIO_FileWriteOptions.htm is saving tons of unnecessary data i guess @Jarek is also fighting with it is it so hard to write only selected models materials to that file do i really need 200 others when I do that in complex scene? The only way of cleaning them is to reload and purging - I will certainly do it via File3dm so I would like to know at least if i should do only materials cleaning or there is more garbage kept?

Note: Don’t tell me i should use File3dm for writing/reading if I want fancy handling as there is no way to cast for eg. InstanceDefinition to InstanceDefinitionGeometry and without it there are always some parts missing in it (just as example)

Next differences in v5 and v6 - what is the purpose of showing in command prompt information that file was saved in v6 as this is done via code and it returns bool it should be up to developer if he/she wants to RhinoApp.Write shouldn’t it ?

Due to API - Write3dmFile vs WriteFile and also vs v5 WriteFile - i understand that v6 and v5 writefile is the same (ofc extended by v6 stuff) but what introduces Write3dmFile only that it auto adds extension or it should be v5 writefile and v6 writefile description is good but behavior bad?

I struggle more than a two weeks with proper saving selected assets from the opened file and loading them. Can someone prepare short example but COMPLETE of writing InstanceDefinition with all its properties/attributes etc. (without unnecessary garbage) to a file and reading it back?

Note: I am aware of this one but it is incomplete - API lacks URLs.

Sorry for wall of text about it but working with this IO is a real pain lately - maybe i just have weird needs.

1 post - 1 participant

Read full topic

OpenInEditor() opens material child texture in Textures panel, not Materials panel (v6 & v7)

$
0
0

When using RenderContent.OpenInEditor() on a material’s child texture (from within the Materials panel), the texture is shown in the Textures panel rather than the Materials panel. This differs from the expected/desired behavior seen when selecting a child texture of a Rhino Custom material, where the texture is shown “in place” in the Materials panel.

If the Textures panel is not open, OpenInEditor() still succeeds, but “nothing” appears to happen (in fact it is still selected in the not-visible Textures panel), so it just seems to the user that your button for selecting the child texture does not work. To edit the child texture “in place” the user must select the texture using the Materials treeview, or the material’s breadcrumb nav.

Anyway, that is how things are working here, so I would like to know if this shows a bug, or if there is perhaps some way I need to set the context for OpenInEditor(). Attached is a minimal example that reproduces the described behavior.

TestEditTexture.cs (5.5 KB)

3 posts - 2 participants

Read full topic

Does using a 2 or 4 point create surface method affect the code?

$
0
0

The script, which is written in C# does not work when I use a 4 point create surface method. However, when I create the exact same surfaces with a 2 point surface create method it does work… I don’t quite understand why. I am using Rhino WIP on windows.

Here is the script:

  private void RunScript(Surface srfA, Surface srfB, double radius, double tol, ref object A)
  {
    //Declare an array of surfaces
    Surface[] surfaces = {};

    //Check for a valid input
    if (srfA != null && srfB != null)
    {
      //Create fillet surfaces
      surfaces = Surface.CreateRollingBallFillet(srfA, srfB, radius, tol);
    }

    A = surfaces;
  }

I am using the exact same components, and script:

The GH file:Srf_Drawing_Bug.gh (21.7 KB)

1 post - 1 participant

Read full topic

Sweep 2 Rails fails in RhinoCommon code

$
0
0

Our code for a RhinoCommon plugin command does not give the desired sweep 2 rails behavior in Rhino 6 (Version 6 SR26 (6.26.20126.12201, 5/5/2020).

Errant sweep using RhinoCommon:


Correct sweep using GUI (manual rail/shape selection):

Code:

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Curve curve1 = null;
            Curve curve2 = null;
            Curve line1 = null;

            var curveObjs = doc.Objects.GetObjectList(Rhino.DocObjects.ObjectType.Curve);
            foreach (Rhino.DocObjects.RhinoObject crvObj in curveObjs)
            {
                Rhino.DocObjects.ObjRef objref = new Rhino.DocObjects.ObjRef(crvObj.Id);
                Curve crv = objref.Curve();
                switch (crvObj.Attributes.Name)
                {
                    case "trimCL":
                        curve1 = crv;
                        break;
                    case "intCrv":
                        curve2 = crv;
                        break;
                    case "line1":
                        line1 = crv;
                        break;
                }
            }

            double tolerance = doc.ModelAbsoluteTolerance;

            if (curve1 !=null && curve2 != null && line1 != null)
            {
                Brep[] botmSweep = Brep.CreateFromSweep(curve1, curve2, line1, false, tolerance);

                doc.Objects.AddBrep(botmSweep[0]);
            }

            return Result.Success;
        }

We’ve also tried the CreateFromSweep overrides and the SweepTwoRail class. Any additional suggestions would be appreciated.

1 post - 1 participant

Read full topic

Viewing all 8549 articles
Browse latest View live