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

Dynamic Updates while in Windows form - Python

$
0
0

Erick Katzenstein wrote:

I'm looking to create a script which colorizes a curve based on distance to a camera. For this, I'm using a Windows Form to select the colors, and need to freely navigate in the Rhino Viewport while the windows form is open. This navigation will update the color, and since the camera is moving during this navigation, the Python script needs to be looping as well to change the color of the curve.

The python script attached is currently not looping while the Windows form is open. The script works once the colors are selected and the form is closed. How does one allow the Python script to loop, while the form is open, and while navigating in Rhino?

curvePoint.py (3.7 KB)

Posts: 3

Participants: 2

Read full topic


ScaleObject and TransformObject behaviour

$
0
0

Andras Sobester wrote:

Hello,

I am encountering problems with scaling an object at different factors in x, y, z. Here is what I am trying to do:

# FuselageOMLSurf is the result of a complex, parametric script. I am trying to scale it by 5 in the y direction and 10 in the z direction here (though in my actual script Scaling is the argument of the function) 

Scaling = [1, 5, 10] 

FuselageOMLSurf = rs.ScaleObject(FuselageOMLSurf, (0,0,0), Scaling)

When I first run it, this produces the expected result: FuselageOMLSurf stretches by a factor of 5 in the y direction and 10 in the z direction. However, after a few runs it starts mixing up the axes and will stretch it in the z direction by a factor of 5 and y by a factor of 10, etc.

My suspicion is that this has something to do with the line "Scaling is based on the active construction plane." is the ScaleObject header, but I don't know how to ensure that it all happens in world coordinates.

I don't use construction planes - at least, not knowingly! I have also tried:

Scaling = [1, 5, 10] 

xform = rs.XformScale(Scaling)

FuselageOMLSurf = rs.TransformObjects(FuselageOMLSurf, xform)
   

This seems to have the same (inconsistent) result.

In either case, if I open a new document, the first time I run the script the result is as expected. But if I delete the resulting objects and re-run the script, it starts getting hit and miss.

Any help would be much appreciated.

Posts: 6

Participants: 2

Read full topic

How to extract viewport meshes of clipped view

$
0
0

Riccardo Gatti wrote:

Hi guys,
I would like to render cutted object without using the boolean to cut it.
I ask if would be possible to extract the current render meshes from a view with a clipping plane applied using a PY or Rhino.common scripting.
Thanks

Posts: 1

Participants: 1

Read full topic

Have something wrong in the function AddInterpCrvOnSrfUV() -Python

Change the Text Alignment via script

$
0
0

laurenz andritz wrote:

Hello all,

is there a chance to change the Orientation/Alignment of a Text Object?

in VB, I am looking for something like:

Dim newtext As New Rhino.display.Text3d (txt, pl, size)
/*newtext.ChangeTheOrientationSomehow(Orientation)*/
doc.Objects.AddText(newtext, atts)

Any ideas?
Thanks in advance, Laurenz

Posts: 3

Participants: 3

Read full topic

Wish new Python function AddRailRevSrf like VbScript

$
0
0

vittorio wrote:

Hi Steve
Can you add a new rhinoscriptsyntax function rs.AddRailRevSrf(........) ?
Ciao Vittorio

Posts: 4

Participants: 2

Read full topic

RhinoPython rs.Command("_-Helix

$
0
0

David wrote:

Hi guys,
Unable to find anything in RP with regard to creating a helix using scripting so
have to use rs.Command. The inputs for the start and end of the helix axis, along
with a point positioning the helix radius, seem ok but cannot input the pitch and number of
turns.

import rhinoscriptsyntax as rs
import math
import Rhino
import System

Helix_Length = 20.0
Helix_Radius = 3.0
Helix_Pitch = 2.0
Helix_Turns = Helix_Length/Helix_Pitch
Axis_StartPt = rs.AddPoint(0,0,0)
Axis_EndPt = rs.AddPoint(Helix_Length,0,0)
Pt_1 = rs.AddPoint(0,Helix_Radius,0)

Helix_Path = rs.Command("-Helix selid " + str(AxisStartPt) + " selid " +str(Axis_EndPt) + " selid " + str(Pt_1) + " _Enter _Enter ")

RP does not ask for the pitch or the number of turns NOR are the default values use.
Thus no helix!

Posts: 2

Participants: 2

Read full topic

Rhino Python or VB Script?

$
0
0

Filip Rooms wrote:

Dear Rhino community,

We plan to invest in writing software in Rhino.
At the top level, We would do this in C# in the .net environment.

Large parts of the software however are just a sequel of steps and we believe that it could be less work to write it in a script format. (or are we mistaking?)

Up till now, we only have experience in VbScripting. What are potential the advantages of Python next to VbScripting in Rhino?

Would it be beneficial to invest in python for the scripting part?

Looking forward to your answer

Posts: 3

Participants: 3

Read full topic


Select a set of brep edges

$
0
0

Gianpaolo Savio wrote:

Hi all,
I need to select a set of edges of a brep in order to run a fillet by a Python script.
I wrote the following in order to select the edges, but nothing is selected:

import Rhino
import scriptcontext

def edgeB():
    filter = Rhino.DocObjects.ObjectType.PolysrfFilter
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select first set of polysurfaces", False, filter)
    if rc != Rhino.Commands.Result.Success: return rc
    if not objref: return Rhino.Commands.Result.Failure
    brep = objref.Brep()
    bre = objref.Object()
    edgelist=brep.Edges
    for i in edgelist:
        if i.Degree>1:
            print bre.SelectSubObject(i.ComponentIndex(),True,True)
scriptcontext.doc.Views.Redraw()
edgeB()

There something wrong in my script?
Thanks,
g

Posts: 9

Participants: 3

Read full topic

Pass an array to Rhino.Command?

$
0
0

Sam Page wrote:

In RhinoScript I'm trying to make something like a rotate around curve, and what I want to do is to pass an array of objects to rotate

Rhino.Command "Rotate3d SelID " & arrObjects

I could use Rhino.GetAngle and then Rhino.RotateObjects instead, but was hoping to to use Rhino.Command "Rotate3d" so the user could get a preview of the geometry rotating about. Any ideas?

Thanks,
Sam

Posts: 3

Participants: 2

Read full topic

How to use rhinopython to MAKE 2D

Native python calls for import STL and section objects?

$
0
0

Filip Rooms wrote:

Dear community,

Just a simple question: is there a native function call to section an object in python?

I know that I can call the command like

   rhino.command "_section w0,-400,0 w0,400,0 _Enter"

but can this be done directly in Python or C# using functions instead of Rhino commands?

Same question for importing e.g. STL files: I know how to do it using a Rhino command, but wonder if this can be done directly in python or C#...

Kind regards,

Filip

Posts: 2

Participants: 2

Read full topic

Call python class from another file

$
0
0

Filip Rooms wrote:

Dear community,

Hope this is an inappropriate question, since it involves pure python. Anyway:

I have a single file main.py with following code

class MyStudent:
    def __init__(self,n,a):
        self.full_name = n
        self.age = a
    def get_age(self):
        return self.age

def CountToTenFunction():
    for i in range(0,10):
        print i

if __name__=="__main__":
    CountToTenFunction()
    x = MyStudent("Jan", 24)
    print x.get_age()

which works fine.

However, when I move

class MyStudent
def CountToTenFunction()

to another file, which I call CountToTen.py

and in my main.py include this file by

from CountToTen import *

only my function CountToTenFunction() is found, but not my class. This gives the error

Message: name 'MyStudent' is not defined

So as a Python beginner, I did something wrong obviously, but have no idea what. Any suggestions?

Many thanks in advance...

Kind regards,

Filip

Posts: 5

Participants: 2

Read full topic

Vbscript runtime error running distribute after update yesterday

How to exit a PythonScript?

$
0
0

CaJoDo wrote:

Here the user interface:
if you press the CancelButton in the User-Interface the code enters line 611 (Dialog is shown)
here the SourceCode

nothing is working...the code will continue execution

THX for help Carsten

Posts: 4

Participants: 3

Read full topic


Splitcurve with points

$
0
0

Alice wrote:

Hello,

I have generated a curve using AddInterpCurve from a list of points. This curve is called "curveGen"

I have another list of 4 points which are in the list param[]

I have converted the points in param[] into curve domains using curveclosestpoint

When I try to splitcurve like so: rs.SplitCurve(curveGen, param)

It only splits the section between the first point which I used to draw curveGen and the first point from param[]

Can someone tell me what the problem is? I am a beginner! Thank you in advance

Posts: 2

Participants: 2

Read full topic

Mac OS Python

$
0
0

Flip Phillips wrote:

Greetings- I am trying to get started with a little Rhino/Python on Mac OS X.
It would seem that I need the RhinoCommon or some other interface (eg- the python imports) and, while the interface is documented well, I can't seem to find where to download anything.

There are mentions like this on GitHub:

Start Rhino and run EditPythonScript or RunPythonScript. This will cause the python plug-in for Rhino to unpack the scripts defined in this project to your computer.

but those commands don't exist on the Mac 5.0 version.

(NB- I am protanomalous (eg Red Colorblind), and all the red links -really- make it hard to find links on the Wiki, so I apologize in advance if I'm missing something simple here.)

EDIT- never mind, found what I needed at http://wiki.mcneel.com/rhino/mac/python (the red links strike).

Posts: 1

Participants: 1

Read full topic

Python Editor Auto Completion

$
0
0

Poltak wrote:

Hi. I just have a problem. I just reinstalled Rhino and I don't know if I always had this problem.
When I use the Python Editor and start to write, the editor doesn't give me hints for the auto completion of the actions.

For example:

import rhinoscriptsyntax as rs
points = rs.G (normally there is the drop down menu for Getxxx)

I hope you can help me.
Thanx

Posts: 3

Participants: 2

Read full topic

Prompt for sub-object surface selection?

$
0
0

violine wrote:

I apologize in advance for probably silly questions here, I am writing my first Macro but do not know how to prompt to select a sub-object surface, is it possible? Thank you!

Posts: 3

Participants: 2

Read full topic

Repeatly make points and group

$
0
0

Baasab wrote:

I want to make a button. When clicking the button I want to place points repeatly. (!_points)
after placing the points regardless how many, I want to click enter and then the last created points have to be grouped.

then when I enter again I want it to start all over again.

I want to use it with a 3D digitiizer. in this way I have grouped points of different parts without touching the computer. which saves me a lot of time.

can someone help me out?

thanx a lot.

Baasab

Posts: 2

Participants: 2

Read full topic

Viewing all 4159 articles
Browse latest View live


Latest Images