Quantcast
Channel: Scripting - McNeel Forum
Viewing all 5865 articles
Browse latest View live

Change radius of circle

$
0
0

Looking for a way to change the radius of a circle using Python in Rhino6. Rhino Common Ok to use. Thanks.

Eric

3 posts - 2 participants

Read full topic


Different results when calculating curve offsets

$
0
0

Hey there,

so i stumbled again upon this strange behaviour in RhinoCommon using Python and i`m wondering where it is originating from.

When offsetting the same curve with Curve.Offset or Curve.OffsetNormalToSurface the results are different on a suprisingly big scale. The underlyling surface is not really complex. Can somebody explain to me what is happening and if there is a fix ?

Attached i’m sending you the script and the geometry.
CurveOffset_Sample.3dm (95.9 KB) Curveoffsets_3ax.py (3.0 KB)

Thanks

Patrick

1 post - 1 participant

Read full topic

Expected Point, got Point

Creating a processing-like Animation class in RhinoPython

$
0
0

I have posted an example on GitHub for creating a processing-like animation using RhinoPython, which is lighter than using Grasshopper’s timers and makes the code more maintainable because the animation is complete in RhinoPython.

Since rhinoscriptsyntax bakes objects into scriptcontext, it is too heavy for animation. So I answered the need to use the Dynamic Draw methods in DisplayPipeline Class of RhinoCommon. This may be a sample that you may not have expected to find. Please give it a try.

1 post - 1 participant

Read full topic

Help - macro toggle between two commands

$
0
0

Hi, i’ve never scripted anything in rhino, but i would like to know if there is a way for me to create a macro that alternate between two commands e.g. 2 display mode or align the gumball to world/object

3 posts - 2 participants

Read full topic

3d DLA question(Diffusion Limited Aggregation)

$
0
0

Hi all,

I’m here with another DLA related question, I am trying to now generate a DLAsystem using ghPython, previously I learned how to do it in 2d and now im trying to create it in 3d, I followed an example and have gotten to this far, but I could not figure out what is the problem now. for example, when the Run is set to Ture, I get the error message that states " ExpireSolution() takes exactly 2 arguments(1 given)", why is that? isn’t it only take one bool argument?

How do i get the particles to stick?

your answer would be much appreciated!

Thank you!!

question screen shot|690x326
DLA.gh (49.5 KB)

3 posts - 2 participants

Read full topic

Draw point with Rhino.Display.DisplayPipeline.DrawDot() in RhinoPython?

$
0
0

Hi,

Does somebody have an example on how to draw a Rhino.Geometry.Point3d() with Rhino.Display.DisplayPipeline.DrawDot() in RhinoPython?

Am I right in the assumption that this method just draws a dot with a shader?

Thanks.

1 post - 1 participant

Read full topic

Expiresolusion error

$
0
0

Hi,
I am trying to use the Expiresolution() in Ghpython, however, i get this message: ExpireSolution() takes exactly 2 arguments(1 given). However, when i look at the documentation, it says it takes in one bool value, if im not mistaken, also, I saw examples online that one bool value seem sufficient what went wrong? can someone help?

Thank you so much!

4 posts - 2 participants

Read full topic


Make2d set output layers

$
0
0

Hi,

is there a way to script make2d command with defining output layers in Rhino 7, in way like in Rhino 5?

in rhino 5 I was using

rs.Command(" -Make2D DrawingLayout=CurrentCplan "
+"ShowTangentEdges=Yes "
+"CreateHiddenLines=Yes "
+"MaintainSourceLayers=No "
+'VisibleLineLayer "CON visible" '
+'VisibleTangentsLayer "CON visible tan" '
+'HiddenLineLayer "CON hidden" '
+'HiddenTangentsLayer "CON hidden tan" '
+'AnnotationLineLayer "CON annotation" Enter ',
False)

I managed to script all except the output layers…

command =   "-_Make2D _Layout=CPlane _Properties=ByOutputLayers _CreateHiddenLines=Yes _ShowTangents=Yes _GroupOutput=No Enter Enter"  
rs.Command(command, False)

I could loop through the output curves and change their layer, but is there a direct way?

Thanks in advance,
Aleksandar

1 post - 1 participant

Read full topic

Rhino 7 behaving slower?

$
0
0

Rhino 7 looks for me like it is behaving slower with Grasshopper Python and C#
I do not know if it is a problem with my computer or what ? but I wonder if someone else feels the same ? could someone test this Gh script with a nested for loop and let me know. I am afraid I did something wrong? But Rhino and Gh crash or take too much time to update each time I move a slider! How could I fix this? thanks in advance!

GridPoints-PointAttractor-PythonToC#.gh (17.4 KB)

1 post - 1 participant

Read full topic

How to run a *.cs script?

$
0
0

i’ve got a script i found that is an *.cs file, the syntax looks like rhino but i’ve never medded with c scripts before.

thank you

3 posts - 2 participants

Read full topic

Error with rs.OffsetCurve (rhino5)

$
0
0

I am trying to script offset of simple closed shapes (rectangles and concave shapes with no crossing lines nor any interior voids).
rs.OffsetCurve will fail for some parameters when my understanding of geometry and the manipulation says it should work.

rectangles work correctly: e.g. rectangle (100,100 - 500,500)
vector 0,0,0 offset= 75 = outside
vector 0,0,0 offset= -75 = inside

for a convex shape (like an outlined U or rectangle as above with hole rectangle (200,200 -400, 500) so these points:
100,100,0
500,100,0
500,500,0
400,500,0
400,150,0
150,150,0
150,500,0
100,500,0
100,100,0

vector [0,0,0] offset = 20 = outside
vector [0,0,0] offset = -20 ERROR (Thinnest portion is 50 wide, so 20 inset should leave 10mm space and be valid).

using curvecentroid[rhino with offset.3dm|attachment]
[0,0,0] offset = -20
ac = rs.CurveAreaCentroid(newcurve)
offCurve = rs.OffsetCurve( newcurve, ac[0], -offsetnum )
works but is still outside. it should be inside. It will work properly, if i manually select a point say(450,200) that is inside shape, but farther from edge than the offset amount. This is hard to generalize to make a program.

my understanding of vector from the vague description (after experiments) is that for offset >0, that the nearest curve point moves closer and then the rest of the curve is on that side of original curve. Is that reasonably correct?

How can I programmatically offset inside and outside for concave and convex shapes?

Sample code and rhino file attached.

  1. for toolpath, select the object on ‘toolpath’ layer
  2. for shape use any line on ‘shape-u’ layer

rhino with offset.3dm (115.5 KB)
offset test.py (2.4 KB)

1 post - 1 participant

Read full topic

PolyCurve Segments

$
0
0

Hi,

I believe a PolyCurve can be made up of different line types, like straight lines and arcs? If this is true is there a way to gain access to each segment to control, for example, the end points of line or the radius and center point of an arc. I understand that if the curve is converted to a Polyline one does have access to the points. Problem is polylines with arcs have many points around the arcs.

Here is a screen shot where I have marked the points of a polyline. You can see the arc problem when converted to a polyline.

Any help with this would be appreciated.


8 posts - 2 participants

Read full topic

GetObject can´t select only curves

$
0
0

Hi,

I try to select only curves with a GetObject( ) using GeometryFilter = ObjectType.Curve but the edges of a mesh are included in at the possibilities os selection.
How can I select only Curves?

Thanks

5 posts - 3 participants

Read full topic

rs.GetPoints() method - in_plane option is 'too constrained'

$
0
0

The optional argument currently accepts only a Boolean value to constrain the points to the active CPlane (True) or not. Methinks this is too limited - instead of a binary yes/no answer, why can’t this input be a plane - any plane - and not just an option to use the active CPlane or not. It would add a lot to the flexibility of the method.

I think the code could be modified to accommodate this without breaking existing scripts…

Current excerpt:

    if in_plane:
        gp.ConstrainToConstructionPlane(True)
        plane = scriptcontext.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
        gp.Constrain(plane, False)

Maybe could be:

    if in_plane:
        if isinstance(in_plane,Rhino.Geometry.Plane):
            gp.ConstrainToConstructionPlane(False)
            plane=in_plane
        else:
            gp.ConstrainToConstructionPlane(True)
            plane = scriptcontext.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
        gp.Constrain(plane, False)

Or something like that…

1 post - 1 participant

Read full topic


Nurbs to mesh in python

$
0
0

Hi,

I have a few Nurbs generated with rs.AddSphere in my python script and I wanted to convert them into meshes within the script. However, it does appear there is a rhinoscriptsyntax MeshToNurbs command but not the opposite NurbsToMesh.

The only work around I thought was to use the grasshopper component MeshSphere, see code below, however the spheres do not seem to appear after generated, and for example I can’t change their colour. Should I do some baking somehow?

Any alternative way to convert a nurbs to a mesh (without sampling it and running a tesselation) you can think of?

import ghpythonlib.components as comps

sp1 = rs.AddSphere(pt, 2) #not needed if I use the component below
sp = comps.MeshSphere(pt,2,3,3)
rs.ObjectColor(sp, color)

Error message: Message: iteration over non-sequence of type Mesh

4 posts - 3 participants

Read full topic

Rhino.MaterialColor to RGB values?

$
0
0

Hi,

I have a problem to read rgb values in Rhinoscript as Rhino.MaterialColor returns something like this:
11908533
That’s supposed to be grey… How to decode it to r / g / b values?

… I solved this as mentioned in later posting… But is there a way to determine MaterialTexture size in RhinoScript?

3 posts - 2 participants

Read full topic

Please help me to exit While Loop in python when I press the enter key

$
0
0

I want to know how to exit While Loop when I press the enter key.

I want to do a specific action until I press Enter.

Please give me a simple example.

The code I tested.

import rhinoscriptsyntax as rs

while True:
rs.Command(’_circle’)
n = input('enter : ')
if n == ‘’:
break;

2 posts - 2 participants

Read full topic

Merge Point Clouds (IronPython)

Click Limit on Long Option List

$
0
0

Is there limits that come with long option lists on GetString, GetLiteralString or Get ?

For example, with the following list you can select the option by using the letter or by clicking on the option until you try to click on the last three. On these you can only select them by typing in the letter. If I add more options then the new options are not clickable. It is like a string limitation is being hit by the click event in some way. It also seems inconsistent between GetLiteralString and Get. I can repeat this behavior on GetLiteralString. On Get this behavior is a bit more erratic.

Best;

Steve

1 post - 1 participant

Read full topic

Viewing all 5865 articles
Browse latest View live