Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5945

Select a Hatch by Pattern - Python & RhinoCommon

$
0
0

@rivex wrote:

Hey Guys

to improve my scripting/coding skills (I'm a programming-beginner ^^), I try to develop basic scripts to make my daily rhinowork faster.

Currently, I'm trying to develop a kind of "Select a Hatch by Pattern" Script, that selects all hatches with the same pattern in Python.

I get stuck at the point, where my script has to select the objects that are stored in a list.
I've tried to use RhinoCommon (RhinoCommon Documentation for this issue, but i got this error:
"Message: expected ObjectTable, got Guid"

(As far as I know, I did everything, that the common-documentation asks for^^)
It sounds like I missunderstood some basic RhinoCommon/Python stuff ^^

Any Ideas to fix this?

My Python Code so far:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
import System

hatchbypattern = []
hatch = rs.GetObject("Select Hatch to select by Pattern", rs.filter.hatch, True, True)

if hatch:
    hatchpattern = rs.HatchPattern(hatch)
    print hatchpattern

allhatches = rs.ObjectsByType(65536)
for i in allhatches:
    if rs.HatchPattern(i) == hatchpattern:
        hatchbypattern.append(i)

for j in hatchbypattern:
    Rhino.DocObjects.Tables.ObjectTable.Select(j, True)

Thanks,
Rivex

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5945

Trending Articles