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

How to cleanup material table using IO File3dm class

$
0
0

I want to purge all materials from file or decide sometimes which need to stay. So I wrote something simple at the beginning:

using (var tempFile = File3dm.Read(tempPath))
{
 tempFile.Materials.Clear();

 tempFile.Polish();
 tempFile.Write(finalPath, Rhino.RhinoApp.Version.Major);
}

But there is no change in final file at all - in both files materials are the same. Am i missing some finalizer or committing changes somewhere ?


Another possible option is that I have to delete also RenderMaterials but those are ofc not available through File3dm IO class …

1 post - 1 participant

Read full topic


Is it possible to carve a text on an object

$
0
0

Hi :slight_smile:
I have a task to carve a text on an object in Unity game engine.
This may be a stupid question so sorry for that :slight_smile:
Is it possible to write a Rhino script that will do that ?
Like create a script that is receiving the object in fbx format and text mesh in fbx format and returning modified object in fbx format?
It must be a 3D printable object.

1 post - 1 participant

Read full topic

What is the rhino c++ api function for cmd Flow?

$
0
0

Hi,
My system is Rhino 6 C++ SDK.
I want to flow a object along a curve by api function, not by run cmd script.
How can I do?
Please give me a sample.

5 posts - 3 participants

Read full topic

RhinoCommon LightObject rotation, size and direction

$
0
0

Hi

How do I get the rotation (ie. amount of spin around the direction of the light) of a WorldRectangular light please?

I also need the length and width of the light source, but the LightObject.LightGeometry.Length (and Width) is a Vector3d rather than a single float. What do Length and Width actually contain please?

EDIT: What I really need is the transformation matrix of the area light (from a 1m x 1m plane).

Thanks

Paul

4 posts - 2 participants

Read full topic

Retrieving a points name and translate that value into a vector

$
0
0

I am new to VBScript and am attempting to make my first GH component and am in need of some direction. The initial goal of the script is to retrieve the name of a given geometry, in this case a point and then move that point to the elevation specified by the name. I am attempting to retrive the name from here:
Capture01

Below is an image of the gh file I’m using as reference:

What I’ve written so far:

Private Sub RunScript(ByVal Point As Point3d, ByRef Output As Object) 

    Dim strName As String
    Dim go As New rhino.DocObjects.ObjectAttributes

    go = Point
    StrName = go.Name
    Output = StrName
End Sub

It is clear that Rhino.Geometry.Point3D cannot be converted to Rhino.DocObjects.ObjectAttributes and I am unsure how to make that conversion happen or if I am even going in the right direction.

Thanks for the help,
Bryce

2 posts - 2 participants

Read full topic

Set Icon broken in latest SR candidate?

$
0
0

Our plug-in stopped working in the latest SR26 candidate because setting the Icon property of a dialog now throws the error below. This issue is new as of the latest SR candidates (that is, it does not occur in SR25). I should mention that we are building against SR18, but the same error occurs when building against SR25. Will we have to move up our references for SR26? This is of course doable, but highly undesirable, as most institutional users (large firms, universities, etc.) do not update Rhino frequently.

System.ObjectDisposedException: Cannot access a disposed object.
   at System.Windows.Media.Imaging.BitmapSource.CriticalCopyPixels(Int32Rect sourceRect, IntPtr buffer, Int32 bufferSize, Int32 stride)
   at System.Windows.Media.Imaging.BitmapSource.CriticalCopyPixels(Int32Rect sourceRect, Array pixels, Int32 stride, Int32 offset)
   at System.Windows.Media.Imaging.BitmapSource.CopyPixels(Int32Rect sourceRect, Array pixels, Int32 stride, Int32 offset)
   at System.Windows.Media.Imaging.BitmapSource.CopyPixels(Array pixels, Int32 stride, Int32 offset)
   at MS.Internal.AppModel.IconHelper.CreateIconHandleFromBitmapFrame(BitmapFrame sourceBitmapFrame)
   at MS.Internal.AppModel.IconHelper.CreateIconHandleFromImageSource(ImageSource image, Size size)
   at MS.Internal.AppModel.IconHelper.GetIconHandlesFromImageSource(ImageSource image, IconHandle& largeIconHandle, IconHandle& smallIconHandle)
   at System.Windows.Window.UpdateIcon()
   at System.Windows.Window._OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.Window.set_Icon(ImageSource value)
   at Eto.Wpf.Forms.WpfWindow`3.set_Icon(Icon value) in D:\BuildAgent\work\commercial\src4\DotNetSDK\Eto\src\Eto.Wpf\Forms\WpfWindow.cs:line 378

Thanks,

Jon

1 post - 1 participant

Read full topic

How do I set predefined path to CRhinoGetFileDialog (c++)?

$
0
0

Hi;
In my code, how do I set predefined path?

CRhinoGetFileDialog gf;
	gf.SetScriptMode(context.IsInteractive() ? FALSE : TRUE);
	BOOL rc0 = gf.DisplayFileDialog(CRhinoGetFileDialog::open_rhino_3dm_file_dialog, 0, RhinoApp().MainWnd());
	if (!rc0)
		return CRhinoCommand::cancel;

2 posts - 2 participants

Read full topic

Wish: publish rdk procedural texture algos

$
0
0

It’s not like some other 3D application is gonna steal Rhino customers by copying them, and it would sure be nice to be able to replicate them faithfully in our engines and avoid baking.

1 post - 1 participant

Read full topic


Feature or plugin idea? kbSnap?

$
0
0

I’ve been inspired by the selection system on qutebrowser. It basically puts a two-character cue on each selectable thing so you can just type the two character tag to make that selection.

This got me thinking about a selection strategy to cut down some percent of the traffic to and from the mouse in Rhino.

What if you could run a command/alias something like kblnee (keyboard selection mode, make a line, use end point snaps for both ends of line)

So then the user is presented with selection cues in the viewports representing all the possible end points to snap to. and you just type jd or whatever and then move on to the next keyboard snap. Then the cues go away.

Ideally the snap point coordinates would be used in some kind of 3-dimensional checksum style algorithm to help assign the alphabetical codes… i.e. so they’re repeatable based on location. i.e. a snap location at the world origin always works out to be aa or whatever, and then random substitutions are considered afterwards to resolve conflicts if needed. Just so as you work with a model over a long period of time routine selections can become automatic.

Perhaps they fade or cull based on distance from camera in perspective just to control clutter. Like you presume the user has the point they want to snap to reasonably conveniently in at least one viewport.

Any thoughts? Could this be crudely prototyped with python? Or perhaps a combination of GH & Python? Just to get something that sortof works on demonstration level and see if it’s practical?

2 posts - 2 participants

Read full topic

C++ FindByUserString

Adding Instance Reference from ActiveDoc to File3dm

$
0
0

I am trying to add Instance Objects from my rhino file to a File3dm to save out.
The Instance Objects are embedded block instances.
I have successfully added the block reference to the new 3dm block manager, but the geometry is still missing. The block manager shows ERROR no geometry found for block definition.

                if (partObject is InstanceObject iref) {
                    var idef = iref?.InstanceDefinition;
                    file.AllInstanceDefinitions.Add(idef);
                    file.Objects.AddInstanceObject(idef.Index, iref.InstanceXform, iref.Attributes);
                }

I have tried to use the example from this post, but it uses geometry that was not previously placed in the file.

2 posts - 2 participants

Read full topic

Vertex Numbering and Mesh Mapping

$
0
0

Hello All,

I’m working on a numerical procedure with meshes and lines. I retrieve a number of meshes and lines, each one with some properties (density, initial stresses, etc). What I need is to have a unique Vertice List containing all meshes and lines vertices, and apply to each mesh face and line the corresponding indice of the new Vertice List. My latest strategy was to create a empty Point List and loop for all mesh faces and lines, adding the vertices that are not contained in the point list yet. However for large problems it is highly time consuming. Here is the routine for the meshes (lines are very similar), where Node is a class that contain a Point3D and a indice and NFD is a class that contains three nodes (triangular mesh face) and its properties:

List<Point3d> points = new List<Point3d>();
List<Node> nodes = new List<Node>();
int id=0;
foreach (NFD nfdens in nfd)
        {
            foreach (Node node in nfdens.nodes)
            {
                if (node.point.DistanceTo(Rhino.Collections.Point3dList.ClosestPointInList(points,node.point))>0.001)
                {
                    points.Add(node.point);
                    nodes.Add(node);
                    node.index = id;
                    id++;
                }
                else
                {
                    int idx = Rhino.Collections.Point3dList.ClosestIndexInList(points, node.point);
                    node.index = idx;
                }
            }
        }

Now I got the ideia to use the Append and CombineIdentical Methods in Mesh class on RhinoCommon, so I would retrieve directly the vertices of the joined meshes, and them i just do the older checking for the lines. However as my meshes have diferrent properties attached to each one, I would need something to map the older mesh vertex indices to the new ones. Any ideia on doing that? Or even a better way of doing this? (Ideally I would like to minimize the bandwidth of the adjency matrix of the Graph containg the lines and mesh edges as edges and the nodes as vertexes)
Here is the code i’m thinking of by now:

List<Mesh> meshes = new List<Mesh>();
Mesh overallmesh= new Mesh();
foreach (NFD n in nfd)
         {
              meshes.Add(mesh);
          }
  overallmesh.Append(meshes);
  overallmesh.Vertices.CombineIdentical(true, true);
  //Apply the line routine
  //Retrieve the new Node List
  //Retrieve mapping from the original elements vertexes to the new Node List

1 post - 1 participant

Read full topic

Print within c# class

$
0
0

Hi all,

I am trying to use Print(msg) within a class in c# component and got this message - Error (CS0038): Cannot access a non-static member of outer type ‘Script_Instance’ via nested type ‘Script_Instance.Island’ (line 206). Any idea?

Thanks in advance.

W

2 posts - 2 participants

Read full topic

Wait interface Redraw

$
0
0

Hello

I have a class that I use with my skin, basically do this:

RhinoApp.RunScript("_-New _None", false); // Open New Document
Rhino.RhinoApp.RunScript("_ViewportTabs _Hide=Yes  ", false); // Hide Tabs
Rhino.RhinoApp.RunScript("_SetDisplayMode  _Viewport=Active _Mode=Ghosted _Enter", false);
Rhino.RhinoApp.RunScript("_Grid  _ShowGrid=No _Enter", false);// Hide a Grid
Rhino.RhinoApp.RunScript("_Gumball _Off=Yes", false);
RhinoApp.RunScript("_PrintDisplay _State=On _Color=Print _Enter", false);

Whenever rhino opens a new document, always shows the construction of the viewports, there is an equivalent command to “RhinoDoc.ActiveDoc.Views.RedrawEnabled = false;”? to only show document
after fininsh the construction.

Thanks

3 posts - 2 participants

Read full topic

Point Rotation

$
0
0

I was wondering if there is some quick way to get point rotation. I’m asking as when a point is rotated using gumball the gumball remembers its state - ofc it can be that gumball remember state per doc object id - but maybe there is some option to read transform of it or can be achieved only implementing custom doc object doing from the ground up kinda “pivot” point?

3 posts - 2 participants

Read full topic


C# component crashes when generating List

$
0
0

Hi!

My c# component crashes when I try to return a list of points and only works when I return a single point.
I can´t see what I´m doing wrong. Help. Thanks.
Code below:

3 posts - 3 participants

Read full topic

Rhino3dmIO Geometry.Leader Plain Text empty

AssemblyInfo Guids between Food4Rhino, Rhino, Grasshopper, Yak files

$
0
0

When creating an accompanying set of plugins for Rhino and Grasshopper (or seperately), there are quite a lot of places where Guids seem important. It is for me not very transparent how or when they are used.

Rhino project:

  • in your Properties/AssemblyInfo.cs you can define a Guid
    [assembly: Guid("%GuidForRhinoRhp%")]

Grasshopper project:

  • in your Properties/AssemblyInfo.cs you can define a Guid
    [assembly: Guid("%GuidForGrasshopperGha%")]

  • in thee class that derives from GH_AssemblyInfo, with a Guid
    public override Guid Id => new Guid("%GuidForGrasshopperAssemlbyInfo%");

  • For yak: you somehow need to specify this in the manifest.yml file. The documentation specifies it looks for a the AssemblyInfo.cs for Rhino, and for the GH_AssemblyInfo for Grasshopper. Does that mean that they should be same when combinding both?

  • For food4rhino, the field specifies only specifies GUID: when and or where would this id be used?

My questions are:

  • Are all these 3 relevant?
  • Can all these 3 be the same?
  • Should they be the same?
  • What would be the concequences of a guid changing?
  • In what scenarios are these 3 guids relevant?

1 post - 1 participant

Read full topic

AddText() disabling "orient text towards reader when viewed from behind" in code

$
0
0

Good evening,

I have a problem when creating a text with Python. In the default text style the option for “orient text toward the reader when viewed from behind” is checked. Of course I could change that option in the template, but what if I wanted to control this in my code?

If not, is there an option to set the textstyle via code? This woudl be really comfortable.

This is the code I am using. All variables not specified here are set in the code above via rhinoscriptsyntax.

Option 1

text_entity = Rhino.Geometry.TextEntity()
text_entity.Plane = pln
text_entity.TextHeight = size
text_entity.Text = text
text_entity.Justification = justification
text_entity.FontIndex = sc.doc.Fonts.FindOrCreate(font, False, False)
item = sc.doc.Objects.AddText(text_entity)
rs.ExplodeText(item, delete=False)

Option 2

item = sc.doc.Objects.AddText(text, pln, size, font, False, False, justification)
sc.doc.Views.Redraw()
rs.ExplodeText(item, delete=False)

5 posts - 2 participants

Read full topic

Capture Image Inside Task

$
0
0

I have this method that captures an image and saves it in a location:

    public void SaveImage()
    {
        string ImageName = @"C:\";
        var doc = Rhino.RhinoDoc.ActiveDoc;
        var view = doc.Views.ActiveView;
        var view_capture = new ViewCapture
        {
            Width = view.ActiveViewport.Size.Width,
            Height = view.ActiveViewport.Size.Height,
            ScaleScreenItems = false,
            DrawAxes = false,
            DrawGrid = false,
            DrawGridAxes = false,
            TransparentBackground = true
        };
        var bitmap = view_capture.CaptureToBitmap(view);
        if (null != bitmap)
        {
            bitmap.Save(ImageName, System.Drawing.Imaging.ImageFormat.Png);
            bitmap.Dispose();
        }
    }

This method works beautifully, but it also takes a little time to execute this method, it is only a little bit but it affects the following functions.

My solution is to run this method within a task: Task.Run(() => saveMat.SaveImage());

Runing with Task, popup “Exception Error”:

I’m not able to find out where this error comes from and why, any ideas?

1 post - 1 participant

Read full topic

Viewing all 8532 articles
Browse latest View live