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

Screen coordiantes to Client coordinates (RhinoScript)

$
0
0

@Jarek wrote:

Is there a way to convert Client coordinate to Screen coordinate (or vice-versa)?

I see XformWorldToScreen and XformScreenToWorld, so the only way I can do the above conversion now is via converting to WorldCoordinate in-between. Any ideas for a direct way ?

I can get a ViewSize and ScreenSize, but I don’t see a way to know the viewport upper-left corner location to do the math, other than converting the Rhino.ViewNearCorners from world to screen/client.

Thanks,

–jarek

Posts: 1

Participants: 1

Read full topic


RS Rhino.AddObjectDisplayMode additional wish

$
0
0

@Jarek wrote:

Hi @Dale,

I’m looking for the ability to pass multiple objects at once to Rhino.AddObjectDisplayMode.
Now cycling through them one-by-one is possible but seems quite slow in terms of the script performance.

If the method changing many objects at is faster, would be great to have it.

thank you,

–jarek

Posts: 1

Participants: 1

Read full topic

V6 Bug: Rhino.UI.OpenFileDialog MultiSelect

$
0
0

@Jess wrote:

Hi,
Rhino.UI.OpenFileDialog does not work with MultiSelect=True
I cannot select anything.
Thanks, Jess

Posts: 2

Participants: 2

Read full topic

Python rhinoscriptsyntax in Rhino6

$
0
0

@Petras_Vestartas wrote:

Hi,

I am trying to run a code via PythonEditor on Rhino6 that is working on Rhino5 without any errors.

Is rhinoscriptsyntax working for rhino6?

I am wondering how to solve these errors in rhino6:

Message: Method not found: ‘Void Microsoft.Scripting.Utils.ExceptionUtils.RemoveData(System.Exception, System.Object)’.

Traceback:
line 67, in , “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\types.py”
line 6, in , “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\abc.py”
line 9, in , “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\numbers.py”
line 8, in , “C:\Users\vestarta\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 8, in , “C:\Users\vestarta\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\application.py”
line 8, in , “C:\Users\vestarta\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript_init_.py”
line 2, in , “C:\Users\vestarta\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscriptsyntax.py”
line 2, in , “Y:\005_Via\Petras\start_V3_CutNotDeep.py”

Posts: 7

Participants: 3

Read full topic

Accessing Advanced Options via script

$
0
0

@Jarek wrote:

Hi All,

Is it currently possible to access (read and change) the Advanced Options in Rhino 6 via scripting (RhinoScript, Python, RhinoCommon) ? The command line has no access to it.
I am trying to modify or disable some options for the script runtime and restore them back once it finishes.

Thanks for any suggestions.

–jarek

Posts: 9

Participants: 3

Read full topic

Drawing and detecting an elliptical arc

$
0
0

@Bianchi wrote:

I’m interested in drawing elliptical arcs (i.e. parts of ellipses) in Rhino. Currently, I’ve tried splitting an ellipse into four parts (not necessarily into quadrants), like so:

e%20arc

However, upon checking the object type and using IsEllipse, IsArc in rhinoscriptsyntax, I get some unexpected results:

rs.IsEllipse: True
rs.IsArc: False

which means I can’t sense that it’s an arc, and that it still registers as an ellipse. What would be a surefire way to generate an elliptical arc that Rhino can sense, and how do I check if a curve geometry is an elliptical arc using RhinoPython / Rhinoscriptsyntax / Rhino common? Would I need to do some math bits first in order to check if it is elliptical?

Posts: 4

Participants: 3

Read full topic

How to get number of cores in Python script

$
0
0

@Terry_Chappell wrote:

I am using tasks.Parallel.ForEach(pieces, helper) that I copied from the Grasshopper parallel.py code to speed up Python when processing a mesh with 2.2M vertices. In order to minimize thread overhead, I divide the data into n pieces where n is the number of threads on my computer. But n is not fixed since I use my laptop (n = 8) when traveling, like now in NYC, and my tower computer (n = 36) when at home in Portland, OR.

My question is, how do I get the number of cores or threads from within a Python script?

I tried:
import os
print os.sysconf(“SC_NPROCESSORS_ONLN”)
but sysconf is not recognized.

I tried:
import multiprocessing
print ‘count =’, multiprocessing.cpu_count()
but import does not find multiprocessing.

I know Holomark shows the number of threads in its summary, but I have not located its source code in order to discover how it obtains this information.

Thanks in advance for your help.
Regards,
Terry.

Posts: 5

Participants: 3

Read full topic

How to delete a mesh face in Python script

$
0
0

@Terry_Chappell wrote:

I have a mesh with 2.2M vertices. I draw a closed curve around a region of interest and collect the curve points and the mesh vertices inside the curve in order to construct a patch mesh. If the curve has concave sides, Rhino adds mesh faces to prevent the patch from having concave sides. I need to remove these in order to get the 3D area of the patch over the closed curve. The way I do this now is to compute the centroid of each mesh face (typically 330K in the region of interest) and test if the centroid is inside the closed curve. I keep the faces found to be inside the curve and construct a new mesh. This takes some time. A faster way would be to just delete the unwanted mesh faces if this could be done inside the Python script. I have not found a Rhinoscriptsyntax command or Rhino Common command that will do this. It can be done with
rs.Command(‘NoEcho -DeleteMeshFaces {},{} Enter’.format(ptc.X,ptc.Y))
where ptc is a face centroid but after it finishes the mesh looks unchanged. If I manually execute the command everything works.

What I really want is a rs.DeleteMeshFace or Rhino Common Mesh.DeleteMeshFace method to get this job done as working with rs.Command is always hazardous (needs to be the right viewport, the viewport needs to already exist, etc.).

Any ideas?

Regards,
Terry.

Posts: 3

Participants: 2

Read full topic


Store list inside 3DM file

$
0
0

@onrender wrote:

Hi, Is it possible to store a list of objects inside the file via IronPython?

I could use this hidden list for pre-selection that could be beneficial in certain cases not to loop through all of the objects in the file just only those in the list.

Posts: 2

Participants: 2

Read full topic

Absolute hide

$
0
0

@onrender wrote:

Hi,

Is there a way to absolutly hide an object that cannot be seen by the reserve command ? It can be revealed by command only. Alternatively I would use layers but what if the object needs to a specific layer.

Posts: 1

Participants: 1

Read full topic

Rhino.ExportViewDisplayMode Bug?

$
0
0

@Jarek wrote:

Hi @Dale,

Over here, both in Rhino 5 and 6 this method: Rhino.ExportViewDisplayMode will not export modes that use technical display pipeline (Technical, Pen, Atristic… plus any other being a copy of them). All other ones export ok and create the .ini file.

Do you see that on your end?
Also, if that doesn’t work - is there any other way with RhinoScript or Python/RhinoCommon to make it work in Rhino 5 as a workaround ?

thank you,

–jarek

Posts: 1

Participants: 1

Read full topic

Phython script from Windows to Mac

$
0
0

@Eggy wrote:

Hello, scripters,

I have a problem. I switched from Windows to a Mac and we used to use a phython script on Rhino on Windows. Now the problem occurs that the script does not work on Mac. The script stops with the error:

AttributeError: ‘NoneType’ object has no attribute ‘Vertices’

I am no hero with scripting but I can understand solutions and we would really like it to work again.
Because I don’t understand how phython scripting is different compared to Mac.
Could anyone help us adjusting this script so that it works on Mac?

Posts: 5

Participants: 2

Read full topic

Script compiler update URL

$
0
0

@tobias wrote:

Hi all,
I ask myself how to use the update url option of the script compiler.
Can someone enlighten me what does it exactly and how to update a compiled plugin with it?

thanks, Tobias

Posts: 1

Participants: 1

Read full topic

Can't import rhinoscriptsyntax to python in grasshopper

Extruding rectangle creates inside-out result

$
0
0

@Helvetosaur wrote:

Can anyone tell me why when I extrude a closed curve such as a rectangle, the result is “inside-out” (the backfaces face outwards)? Doesn’t make much sense to me…

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

r=rs.GetRectangle()  #draw a rectangle in the Top viewport
plc=Rhino.Geometry.PolylineCurve([r[0],r[1],r[2],r[3],r[0]])
ex_vec=Rhino.Geometry.Vector3d(0,0,10)
ext=Rhino.Geometry.Surface.CreateExtrusion(plc,ex_vec)
sc.doc.Objects.AddSurface(ext)
sc.doc.Views.Redraw()

Thanks, --Mitch

Posts: 2

Participants: 2

Read full topic


Cannot run _EditPythonScript . "Failed to load language..."

$
0
0

@wattzie wrote:

Hi,

Following on from this post:

I get the same error:

Error occured loading plug-in
 Details:
Failed to load language 'IronPython 2.7.5': Method not found: 'Boolean Microsoft.Scripting.Utils.ReflectionUtils.IsInterface(System.Type)'.

I do have another version of IronPython installed but I need this to use numpy in the 32 bit Rhino 5. Uninstalling this is not really an option.

Does anyone have an alternative work around?

Posts: 2

Participants: 2

Read full topic

Asynchronous issues with NodeInCode

$
0
0

@Dani_Abalde wrote:

Great Guilio!

I have a question, what about cascading using NodeInCode? that is, create a definition (connected nodes) from code. Should we use asynchronous patterns? what considerations can you add for this?

Thanks!

Posts: 3

Participants: 2

Read full topic

Vbscript polar array

$
0
0

@cshea wrote:

i would like to perform polar array to a curve in vbscript.
which curve method or transform method should I be using please

Posts: 2

Participants: 2

Read full topic

RhinoScript SaveSettings in Python

$
0
0

@Jarek wrote:

I don’t see SaveSettings in RhinoScriptSyntax - is there a way to read/write an .ini file in a similar way in Python?

thanks,

–jarek

Posts: 5

Participants: 2

Read full topic

Bug(?): rs.SelectObjects() redraws after every item

$
0
0

@Holo wrote:

Hi, it seems very unnecessary that rs.SelectObjects() redraws after every object, this should IMO have only redraw after all are selected.

Posts: 3

Participants: 2

Read full topic

Viewing all 5834 articles
Browse latest View live


Latest Images