Skip to content

Commit

Permalink
Ready for initial PR
Browse files Browse the repository at this point in the history
  • Loading branch information
obucklin committed Oct 24, 2023
1 parent 75180f6 commit 31654be
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/compas_timber/ghpython/components/CT_BTLx/code.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
from ghpythonlib.componentbase import executingcomponent as component
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning
from compas.rpc.proxy import Proxy
import Rhino
from compas_timber.assembly import TimberAssembly
from compas_timber.fabrication import BTLx
import compas.data

# from compas_timber.utils.btlx_utils import BTLx_Part
import compas.geometry.brep
from compas.artists import Artist
from compas.geometry import Line

btlx = Proxy("compas_timber.fabrication.btlx")


class WriteBTLx(component):
def RunScript(self, Assembly, Path, Write):

if not Assembly:
self.AddRuntimeMessage(Warning, "Input parameter Assembly failed to collect data")
return

btlx_json = compas.json_dumps(Assembly)
strings = btlx.get_btlx_string(btlx_json)
BTLx, blanks_data, msg = strings[0], strings[1], strings[2]

print(msg)

Blanks = []
for blank in blanks_data:
Blanks.append(blank.from_data)
btlx = BTLx(Assembly)
btlx.history["FileName"] = Rhino.RhinoDoc.ActiveDoc.Name

if Write:
if not Path:
self.AddRuntimeMessage(Warning, "Input parameter Path failed to collect data")
return
with open(Path, "w") as f:
f.write(BTLx)
f.write(str(btlx))

return BTLx, Blanks
return str(btlx)

0 comments on commit 31654be

Please sign in to comment.