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

Default path for saving scripts in Python editor

$
0
0

Mitch Heynick wrote:

I keep my script library in a folder in my Dropbox. In the Python editor options, I have set that folder path, and eliminated the default path : ...\AppData\Roaming\McNeel\Rhinoceros\5.0\scripts

Despite that fact, when I do a Save or SaveAs for the first time in a session, it reverts to that folder, like it was hard coded somewhere... Can you please fix?

Thanks, --Mitch

Posts: 5

Participants: 5

Read full topic


Python Primer Example error

$
0
0

m_ziolo_86 wrote:

Hello,

I am in the course of learning script example from Rhino 5 Python Primer regarding recursion.

I have a function written as below:

def AddArcDir(ptStart, ptEnd, vecDir):
    vecBase = rs.PointSubtract(ptEnd, ptStart)
    if rs.VectorLength(vecBase)==0.0: return

    if rs.IsVectorParallelTo(vecBase, vecDir): return

    vecBase = rs.VectorUnitize(vecBase)
    vecDir = rs.VectorUnitize(vecDir)

    vecBisector = rs.VectorAdd(vecDir, vecBase)
    vecBisector = rs.VectorUnitize(vecBisector)

    dotProd = rs.VectorDotProduct(vecBisector, vecDir)
    midLength = (0.5*rs.Distance(ptStart, ptEnd)/dotProd

    vecBisector = rs.VectorScale(vecBisector,midLength)
    return rs.AddArc3Pt(ptStart, rs.PointAdd(ptStart, vecBisector), ptEnd)

In the line :

  vecBisector = rs.VectorScale(vecBisector,midLength)

I get an error message "SyntaxError: unexpected token 'vecBisector' ". Why do I get this message?

Posts: 6

Participants: 4

Read full topic

Python rs.ObjectLayer() - option to return full layer path

$
0
0

Mitch Heynick wrote:

Right now it returns only the top level layer name, it would be handy to have the full path. This was already discussed awhile back here... so there are workarounds, but again it would be nice to be able to do this directly.

Thanks, --Mitch

Posts: 2

Participants: 2

Read full topic

Python - move layer set under new parent layer

$
0
0

Mitch Heynick wrote:

OK, lets say I have a set of hierarchical layers/sublayers (leave them empty for now), and I want to create a new parent layer and move the entire existing layer hierarchy under it:

I'm having trouble doing this - I thought it would be sufficient to get the full path name to each layer and then add the parent layer name to that at the front: parentName+"::"+layerpathName, then add a layer to the document with that full path. But it doesn't work... Anyone have a logic for doing this?

Thanks, --Mitch

LayerHierarchy1.3dm (35.7 KB)

LayerHierarchy2.3dm (36.0 KB)

Posts: 3

Participants: 2

Read full topic

AddPipe History?

Python/Rhinoscriptsyntax layer/sublayer-related "issues"

$
0
0

Mitch Heynick wrote:

Issue #1:

With a new blank file containing just one layer "Default"...

In vb Rhinoscript, run the following code:

Option Explicit
Call TestAddSubLayer()
Sub TestAddSubLayer()
    Call Rhino.AddLayer("Default::NewLayer")
End Sub

The layer NewLayer is added as a sublayer of Default.

Now, do the same thing with Python rhinoscriptsyntax (start with a new file):

import rhinoscriptsyntax as rs
rs.AddLayer("Default::NewLayer")

A new top-level layer is added with the name Default::NewLayer... Not how it's supposed to work IMO...

Issue #2:

In the file created in the first step above - with a Top layer "Default" and a sublayer "NewLayer" - put one object (anything) on the sublayer "NewLayer"

In vb rhinoscript run the following and choose the object:

Option Explicit
Call TestGetObjectLayer()
Sub TestGetObjectLayer()
    Dim obj : obj = Rhino.GetObject()
    Call Rhino.Print(Rhino.ObjectLayer(obj))
End Sub

Returns: Default::NewLayer

Now, run the Python equivalent and do the same:

import rhinoscriptsyntax as rs
obj = rs.GetObject()
print rs.ObjectLayer(obj)

Returns:  NewLayer

These sublayer issues are driving me nuts - making it very hard to script layer operations with sublayers in python rhinoscript syntax...

IMO, all rhinoscriptsyntax methods need to return the full layer path. Also, for both vb and python, optional arguments to return the layer ID instead of the name would be good.

Thanks,
--Mitch

Posts: 2

Participants: 2

Read full topic

Python ExplodePolysurface method changed

$
0
0

Dan Bayn wrote:

Not sure if this was intentional or not, but I noticed when using the ExplodePolysurface method in Rhinoscript that the exploded surfaces would maintain their layer assignments but in the Python version the exploded surfaces go to the current layer.

Easy enough to work around, but I thought I would point this out.

Thanks,

Dan

Posts: 9

Participants: 3

Read full topic

Rhino.ExtractRenderMesh odd behavior

$
0
0

Jarek Bieda wrote:

I have noticed some inconsistency between how the command and rs method work.
With the command, no matter what types of object I preselect (mix of curves and objects that actually have render mesh) the command will work and extract meshes from whatever it can.

With the RS method, when I feed it the array of mixed types, as soon as there is an element that doesn't have the render mesh (i.e. curve) the method will return Null. It would be more convenient and consistent if the command-like behavior was applied here too. Would it be possible to fix?

thanks~

Posts: 4

Participants: 3

Read full topic


Scripting lots of rotations and memory consumption

$
0
0

Mitch Heynick wrote:

I'm creating a small animation and for that I need to rotate things a lot of times - I have like 150 objects and they rotate around a center as well as around themselves, and the idea is to see the intermediate moves. This is eating up my memory very quickly. Programming ClearUndo in the loop doesn't seem to help.

Any way around this limitation? Otherwise I'm going to need to invest in more memory.... confounded

--Mitch

Posts: 9

Participants: 4

Read full topic

Issue with IEnumerable(GeometryBase)

$
0
0

Djordje wrote:

Been trying to use the CreatePatch method, but got stuck on its first parameter: IEnumerable(GeometryBase).

Seems like @stevebaer already gave an explanation on this issue in here.
Still I am not getting it.
Tried the following code:

from System.Collections.Generic import IEnumerable
from Rhino.Geometry import Point
import rhinoscriptsyntax as rs
import Rhino
import System

pt_ids = rs.GetObjects()
pts = [rs.coerce3dpoint(pt_id) for pt_id in pt_ids]
pointL = [Rhino.Geometry.Point(pt) for pt in pts]

IEGB = IEnumerable[Point](pointL)

got the following error message (one the last line of the upper code):

Cannot create instances of IEnumerable[Point] because it is abstract

I thought that maybe a "conversion" of Point3d needs to be done, as Point class has been derived from GeometryBase. Is this causing the problem?

Posts: 8

Participants: 5

Read full topic

Networkx 1.8.1 on Rhino 5

$
0
0

Mmous Ann wrote:

Dear Friends,
Now I am trying to use network 1.8.1 with rhino python, but I keep having an error massage:

Message: The method or operation is not implemented.

Traceback:
line 23, in copyfunc, "C:\Users\noclew\Desktop\test\networkx\algorithms\isomorphism\matchhelpers.py"
....

I just cannot figure out how to solve this. Does anyone knows how to deal with this issue?

Posts: 7

Participants: 4

Read full topic

Bug in SplitCurve creating 3 curves instead of two

$
0
0

Wattzie wrote:

Hi,

I have a mesh and I am trying to split the outline of the mesh into two curves. This seems relatively simple using rs.splitcurve however this code:

Curves=rs.SplitCurve(Outline,(CuttingPoint1,CuttingPoint2))

(where CuttingPoint1 & CuttingPoint2 lie in the domain of Outline)

gives me 3 curves. It seems like it is splitting the curve at the two supplied cutting points as well as the seam.

Additionally, if I try to move the seam to one of the cutting points:

rs.CurveSeam(Outline,CuttingPoint1)

and then run the splitcurve as above, the curve does not split at all.

For now I am able to get around this by using the TrimCurve function twice however this seems inefficient, especially when it seems like the splitcurve function should achieve this.

Am I doing something wrong with the SplitCurve function or is this a bug?

Posts: 3

Participants: 2

Read full topic

List every object in current document

$
0
0

Sébastien Mennetret wrote:

Hi,

I'm seeking for a way (with python) to list every singl object in document, even if there locked or hided or located in hided layers.

Any clues ?

Regards,

Posts: 3

Participants: 2

Read full topic

NormalObjects

$
0
0

James Carruthers wrote:

I've got a script that uses the NormalObjects function to perform a script on the first/only visible, unlocked (and with other functions) planar surface in a file. It seems to return objects that are locked or hidden.

Posts: 3

Participants: 2

Read full topic

Waiting for user input with aliases

$
0
0

Peter Hennessey wrote:

Hi,

this is more a questions about aliases than scripting, but this seems like the place for it.

I am trying to work out if there is something that will work in an alias to allow me to wait for one command to execute (with a variable degree of user input) and then run another.

Specifically, I'd like to get this to work:

! _CurveBoolean _Group

So that I can run the curve boolean command, do all my selecting and options or whatever, and THEN group the resulting curves.

I've tried PAUSE but that doesn't seem to make any difference.

Any help would be greatly appreciated.

thanks
Peter

Posts: 4

Participants: 2

Read full topic


A script for starting a line at 0

$
0
0

Cosmas Demetriou wrote:

Good morning colleagues,

So I could like an alias for starting a line at 0 in whatever view you happen to be in, so I wrote the following macro:

line startofline=0

... but it didn't work. It seems like it should be simple, but...
Any assistance would be appreciated.

Thank you.

Posts: 3

Participants: 2

Read full topic

Export 20-30 Rhino files to Version 4

$
0
0

Randy Gregory wrote:

Just to say, i am usually on a Mac, but can do Windows if that works.

I am wondering if I can have a script to copy a folder of Rhino 5 files as version 4 files.

I have about 30 to do, and may have more every week or 2. Until I can convince the person to upgrade.

Thanks, Randy

Posts: 10

Participants: 3

Read full topic

Rhino python editor - help for XFormRotation2

$
0
0

Mitch Heynick wrote:

...is incomplete...

should be something like:

Returns a rotation transformation about an axis
angle_degrees = number: rotation angle in degrees
rotation_axis = vector3d
center_point = point3d

Thx, --Mitch

Posts: 2

Participants: 2

Read full topic

Bug in ReadViewportsFromFile

$
0
0

Jørgen Holo wrote:

I try to read the viewports from another file, but it doesn't work perfectly.

It does read in the active viewports, but none of these new names, NOR any of the other views stored in the read file can be found either in NamedViews or in "View - Set View".

Are there any workarounds to read in the views?

I try to import a file and have it act as if the file was "opened".

Or can I open a Read Only file with out the "this is a read only file" warning.

-Jørgen

Posts: 5

Participants: 3

Read full topic

Instance Length , Volume Details

$
0
0

Aashiq Hanif Ahamed M wrote:

Hi

Am successfully reading Length (Curves) , Volume & Surface Area (Surface/Poly surface) from .3dm files using rhino vb script. But In-case of files having Scaled Instance am getting the volume/Length of the original object.What should i do to get the Volume/Length value for the Transformed Object?

I tried Transformobjects() function but its returning the same ID which am passing.Can anyone help?

Thanks,
Aashiq M.

Posts: 2

Participants: 2

Read full topic

Viewing all 4125 articles
Browse latest View live