Comments (4)
You are not importing show
inside of your code text block. This modification fixes the error and prints the exception when there is one.
import cadquery as cq
import textwrap
from cadquery.vis import show
from cadquery import cqgi
TESTSCRIPT = textwrap.dedent(
"""
from cadquery.vis import show
result_in_TESTSCRIPT = cq.Workplane().box(50, 50, 5)
cq.exporters.export(result_in_TESTSCRIPT, "result_in_TESTSCRIPT.step", exportType = "STEP")
show(result_in_TESTSCRIPT)
"""
)
model = cqgi.CQModel(TESTSCRIPT)
result = model.build()
if not result.success:
print(result.exception)
# print(result.success)
print(type(result))
print(len(result.results))
from cadquery.
I mis-think that the third line code "from cadquery.vis import show" do the job. Yes, the first issue is resolved. Thank you, @jmwright.
After executing "model.build()", could we obtain the model of result_in_TESTSCRIPT in the main program (not the TESTSCRIPT script) for the subsequent operations?
from cadquery.
This code is older and unmaintained currently, but is still relevant and gives an example of extracting CQ objects from the CQGI build result object, which would allow you to use them later.
from cadquery.
Thank you very much for you help. @jmwright
My issues are resolved, and the final code is as following.
import cadquery as cq
import textwrap
from cadquery.vis import show
from cadquery import cqgi
TESTSCRIPT = textwrap.dedent(
"""
result_in_TESTSCRIPT = cq.Workplane().box(50, 50, 5)
cq.exporters.export(result_in_TESTSCRIPT, "result_in_TESTSCRIPT.step", exportType = "STEP")
show_object(result_in_TESTSCRIPT)
"""
)
model = cqgi.CQModel(TESTSCRIPT)
result = model.build()
if not result.success:
print(result.exception)
else:
print("success......")
for res in result.results:
print(type(res.shape))
show(res.shape)
from cadquery.
Related Issues (20)
- DXF export for sketch
- Finding coplanar and concentric surfaces HOT 5
- Wrap features (`BRepFeat`) from OCP
- symmetric `thicken`
- Provide Interface to OCCT Messages
- Simple 'cut' of two a Box and a Sphere creates unusable object HOT 3
- Documentation: Assembly tutorial constraint solver result regression HOT 4
- seems parametricCuve()bug HOT 10
- Adding existing geometry into sketches? HOT 1
- Planar surface HOT 1
- Problem of center of mass when a cylinder is generated with a non-default direction HOT 1
- Add selectors for local coordinate system HOT 7
- Assembly top level location ignored
- Selecting a face defined by Sketch on plane HOT 1
- Add docs about referencing subassemlies.
- Working with TDocStd_Document: Empty document when trying to use TDocStd_Application::Open wrapped by OCP HOT 1
- Can one limit the number of cores or threads to run in parallel? HOT 5
- Examples should have more explanations.
- Allow zero x or y spacing Workplane rarray
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cadquery.