Comments (3)
I guess related to materials @davesrocketshop FYI
from freecad.
from freecad.
Instead of setting the 'DiffuseColor' attribute directly, call the following set function, or similar, after making it available. Works on my end.
def setDiffuseColor(vObj, diffuse, transparency=None):
"""setDiffuseColor(vObj, diffuse, transparency=None)
Sets DiffuseColor and optional Transparency of vObj"""
if (isinstance(diffuse, tuple) or isinstance(diffuse, list)) and len(diffuse) == 3:
m = vObj.ShapeAppearance[0] # get current material attributes
if transparency is not None and transparency >= 0.0 and transparency <= 100.0:
t = transparency
else:
t = m.Transparency
vObj.ShapeAppearance = FreeCAD.Material(
DiffuseColor=(diffuse[0] / 255.0, diffuse[1] / 255.0, diffuse[2] / 255.0),
AmbientColor=m.AmbientColor,
SpecularColor=m.SpecularColor,
EmissiveColor=m.EmissiveColor,
Shininess=m.Shininess,
Transparency=t,
)
Just a suggestion.
Example:
setDiffuseColor(self.Body.ViewObject, (204, 204, 230))
... in place of the following:
self.Body.ViewObject.ShapeAppearance[0].DiffuseColor = (0.8, 0.8, 0.90, 0.0)
or
self.Body.ViewObject.ShapeColor = (204, 204, 230)
or
self.Body.ViewObject.ShapeAppearance.DiffuseColor = (0.8, 0.8, 0.90, 0.0)
--Throws an error.
The solution appears to be assigning a new FreeCAD.Material object to ShapeAppearance, rather than being able to edit the DiffuseColor attribute of the existing.
from freecad.
Related Issues (20)
- Start: clicking on text on new file tiles does nothing HOT 2
- TD: Clean-up class GeometryMatcher
- Wrong export in STL (export with errors) HOT 1
- Start:Asking to Which Workbench Selector to Use HOT 3
- Addon Manager Locks up FreeCAD HOT 10
- Navigation cube: mouse click events are not recognized HOT 2
- Sketcher segfaults when using the symmetry tool HOT 10
- FEM: Bug when pre-selecting geometries for some constraints
- [TreeView] Incorrect Label2 view when element is hiden HOT 3
- Sketcher: "Fit All" zoom command in edit mode always includes axis origin HOT 3
- Draft: Exception during shapes editing HOT 2
- Sketcher: "Fit selection" command in edit mode does not fit view to selection HOT 3
- [Feature Request] 3D Constraint-driven sketcher/wireframe workbench HOT 3
- TechDraw: Smart dimension doesn't support thickness annotations HOT 1
- Error on create output for helical cut on fanuc code HOT 3
- Sketcher: ConstraintEqual doesn't accept Line + Arc HOT 2
- Core: "Go to selection" not working HOT 3
- FEM: Results pipeline can't handle cases when output has a single value in the whole model
- Add Favorite Properties
- OndselSolver: Failing to compile with GCC 14
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.