小编Dan*_*öws的帖子

我如何用Python在Blender中读出自定义属性?

我想在Blender本身中使用脚本模式读出Blender对象的自定义属性.到目前为止,我发现只能读出您在脚本模式下自己创建的自定义属性.但是我想读出我自己用手标记的自定义属性.这意味着我没有要使用的局部变量.

我希望它在以下上下文中:我有一个循环遍历所有对象:

for obj in bpy.data.objects:
if not 'Camera' in obj.name and not 'Lamp' in obj.name and not 'Armature' in obj.name:
    #here I get the location of the current Object
    loc.append(obj.location)
Run Code Online (Sandbox Code Playgroud)

现在什么是完美的,将是这样的:

obj.getCustomProperties
Run Code Online (Sandbox Code Playgroud)

有没有办法用Blender Python模式做到这一点?

谢谢,丹尼尔

python blender

9
推荐指数
1
解决办法
4759
查看次数

Jackson Deserializer没有默认(无arg)构造函数

首先,我知道这个问题:CustomDeserializer没有默认(无arg)构造函数

我使用了推荐的解决方案,但仍然存在同样的问题.当我尝试反序列化我的json时,我仍然得到错误.

我想要对我的对象进行自定义反序列化.我的单元测试看起来如下:

Service service = new Service();
service.setId("ID");
service.setTitle("Title");
service.setDescription("Description");
service.setType("Service");

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(service);
Service service2 = mapper.readValue(json, Service.class);
Run Code Online (Sandbox Code Playgroud)

我的反序列化器(包含目前单元测试未涵盖的一些功能,但他甚至没有这么做):

public class ServiceDeserializer extends StdDeserializer<Service> {

    public ServiceDeserializer() {
        super(Service.class);
    }

    @Override
    public Service deserialize(final JsonParser jp, final DeserializationContext ctxt)
            throws IOException, JsonProcessingException {
        DataBaseManagment manager = DataBaseManagmentManager.getInstance();
        List<DataObject> objects = manager.readAll("Utility", true);
        JsonNode node = jp.getCodec().readTree(jp);
        String id = node.get("id").asText();
        String title = node.get("title").asText();
        String description = node.get("description").asText();
        Service service = …
Run Code Online (Sandbox Code Playgroud)

java json jackson deserialization

6
推荐指数
1
解决办法
2825
查看次数

通过在散景中悬停来突出显示多个 hex_tiles

我尝试在十六进制地图中可视化我的数据。为此,我在图形类中使用了 python bokeh 和相应的 hex_tile 函数。我的数据属于 8 个不同类别之一,每个类别都有不同的颜色。下图显示了当前的可视化:

当前可视化 我想添加当鼠标悬停在元素上时更改元素(最好是所有类成员)颜色的可能性。

我知道,这在某种程度上是可能的,因为散景本身提供了以下示例:https : //docs.bokeh.org/en/latest/docs/gallery/hexbin.html

但是,我不知道如何自己实现(因为这似乎是 hexbin 函数的功能,而不是简单的 hex_tile 函数)

目前我在 ColumnDataSource 中提供我的数据:

source = ColumnDataSource(data=dict(
r=x_row,
q=y_col,
color=colors_array,
ipc_class=ipc_array
))
Run Code Online (Sandbox Code Playgroud)

其中“ipc_class”描述了元素所属的 8 个类之一。对于鼠标悬停工具提示,我使用了以下代码:

TOOLTIPS = [
("index", "$index"),
("(r,q)", "(@r, @q)"),
("ipc_class", "@ipc_class")
]
Run Code Online (Sandbox Code Playgroud)

然后我将所有内容可视化:

p = figure(plot_width=1600, plot_height=1000, title="Ipc to Hexes with colors", match_aspect=True,
       tools="wheel_zoom,reset,pan", background_fill_color='#440154', tooltips=TOOLTIPS)
p.grid.visible = False
p.hex_tile('q', 'r', source=source, fill_color='color')
Run Code Online (Sandbox Code Playgroud)

我希望可视化添加一个函数,其中将鼠标悬停在一个元素上将导致以下之一: 1. 通过更改颜色突出显示当前元素 2. 通过更改其颜色来突出显示同一类的多个元素color 3. 元素悬停时更改hex_tile元素(或完整类)外线的颜色

散景可以实现这些功能中的哪些功能,我将如何实现?

编辑:在尝试重新实现 Tony 的建议后,只要我的鼠标点击图形,所有元素都会变成粉红色,并且颜色不会变回。我的代码如下所示:

source = ColumnDataSource(data=dict(
    x=x_row,
    y=y_col, …
Run Code Online (Sandbox Code Playgroud)

python bokeh

2
推荐指数
1
解决办法
744
查看次数

标签 统计

python ×2

blender ×1

bokeh ×1

deserialization ×1

jackson ×1

java ×1

json ×1