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

Write File Python script freezes Grasshopper

$
0
0

Hello Everyone,

I am working on a Python script in Rhino 8 Grasshopper that exports objects from a list of specific layers into a separate .3dm file.
However, the current implementation freezes Grasshopper.

Here is the code I’m currently using:

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import os

if Start:
sc.doc = Rhino.RhinoDoc.ActiveDoc
f_path = hely
if not os.path.exists(f_path):
os.makedirs(f_path)

os.chdir(f_path)
a_d = os.getcwd()

rs.ZoomExtents()
rs.UnselectAllObjects()
fnit     = ""
extt     = ".3dm"
csendt   = " _Enter"

lns  = rs.LayerNames()
objs = list()
for li in Layers:
    rs.LayerVisible(li,True)
    layobjs = rs.ObjectsByLayer(li)
    objs.extend(layobjs)
rs.SelectObjects(objs)

fnit = hely+fn
cs="_-Export "+chr(34)+fnit+chr(34)+csendt

siker = rs.Command(cs,False)
if siker:
    print (fnit+" írása megtörtént")
else:
    print (" HIBA az "+fn+" írásnál!")

rs.UnselectAllObjects()
sc.doc = ghdoc

Does anyone have an idea how to fix this issue?
Any suggestions or corrections would be greatly appreciated!

Thanks in advance for your help!
Frank

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4120