-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |