Comments (4)
Hello,
YES! A few months ago, I made special effort to have so (so I'm pleased to find a client today ;-))
This script should demonstrate the capability, just copy/past in the console:
from os import path
import Render
# Adapt the 2 following lines if you want to change renderer
# Caveat: we assume that the external renderer program has been correctly
# installed and the path to that program has been correctly set in FreeCAD
# parameters
RENDERER, TEMPLATE = "Povray", "povray_standard.pov"
# RENDERER, TEMPLATE = "Luxcore", "luxcore_standard.cfg"
# RENDERER, TEMPLATE = "Cycles", "cycles_standard.xml"
# RENDERER, TEMPLATE = "Pbrt", "pbrt_standard.pbrt"
# Create a new doc
doc = App.newDocument("RenderTest")
# Create a rendering project
template_path = path.join(Render.WBDIR, "templates", TEMPLATE) # This could be made more user-friendly...
_, proj, _ = Render.Project.create(doc, renderer=RENDERER, template=template_path)
proj.GroundPlane = True
# Create an object and add its view to project
box = doc.addObject("Part::Box", "Box")
box.recompute()
proj.Proxy.add_view(box)
# Create a camera, position it and add its view to project
_, cam, _ = Render.Camera.create(doc)
cam.Placement = App.Placement(App.Vector(40, -30, 50), App.Rotation(App.Vector(-0.7, -0.3, -0.6), 300))
proj.Proxy.add_view(cam)
# Render
# wait_for_completion should be set to True if freecadcmd is launched in script
# mode, otherwise freecad will exit without completing rendering.
# to the contrary, in interactive console mode, wait_for_completion may be better
# set to False (default)
img = proj.Proxy.render(wait_for_completion=True)
print(f"Done: {img}\n")
Can you let me know if it is OK for you?
from freecad-render.
cool! It's worth adding these steps to the Wiki/documentation pages.
Basically I want to render floor plan from 2d floor plans
from freecad-render.
@howetuft cool! Thanks!
I will try it later.
How to I initialize "App" ?
Can I call Renderer APIs in a detached python console - not within FreeCAD?
from freecad-render.
How to I initialize "App" ?
Basically, it's already defined in FreeCAD console.
But if you want to redefine it explicitly:
import FreeCAD as App
Can I call Renderer APIs in a detached python console - not within FreeCAD?
Yes, there are 2 solutions:
- Use
freecadcmd
, the console version of FreeCAD. It does not open a GUI, just a console. You can also pass the script as a command-line argument - no console open, just run the script. - Import FreeCAD in a standard Python interpreter. It's more tricky, as you must make Python aware of FreeCAD installation. To do that, you have to add this in the header of the above script:
import sys
sys.path.append("your/path/to/your/freecad/libs")
import FreeCAD as App
For instance, on my Arch Linux system, it resolves into
import sys
sys.path.append("/usr/lib/freecad/lib")
import FreeCAD as App
Just out of curiosity, what is your use case precisely?
from freecad-render.
Related Issues (20)
- Doc: provide a test function for renderer installation HOT 1
- Cycles templates are strange HOT 5
- Cycles needing to be compiled standalone should be made more clear. HOT 29
- Adding materials seems to be broken in latest dev! HOT 14
- [Contest] HOT 3
- File name too long HOT 3
- [feature request] Add emmision material/shader HOT 9
- AttributeError: module 'Material' has no attribute 'MaterialManager' HOT 2
- Render.view.ViewProviderView not JSON serializable HOT 4
- handling of links to std::part broken. HOT 8
- [macOS] ImportError: No module named site HOT 1
- Cycles say: Color management disabled HOT 8
- make_material can't be caller with alpha in color HOT 1
- Editing Material try error HOT 1
- Using ArchMaterial beaks rendering
- appleseed don't render HOT 3
- Merge #358 breaks workbench (init needs to be updated too to reflect removal of set_a2p) HOT 3
- Colors do not work at all with new material-changes. HOT 3
- Does not start anymore with latest FreeCAD 0.22dev and Ondsel ES 2024.2 builds HOT 13
- RUNTIME ERROR: Syntax error in texture name HOT 4
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 freecad-render.