简体   繁体   English

4 个不同类的相同属性

[英]Same attribute for 4 different classes

I have a problem for a script in a 3D GIS software (Infraworks).我在 3D GIS 软件 (Infraworks) 中遇到脚本问题。 I need to say to a 3D model to have the same random value for 4 different attributes, x,y and z scale and z movement.我需要对 3D 模型说,对于 4 个不同的属性,x、y 和 z 比例以及 z 移动具有相同的随机值。 Someone knows how to do it?有人知道怎么做吗?

At the moment I wrote this script, but cause I'm not a proper programmer I don't know if it's the right way.目前我写了这个脚本,但因为我不是一个合适的程序员,我不知道这是否是正确的方法。

[TREES.MODEL_SCALE_X, TREES.MODEL_SCALE_Y, TREES.MODEL_SCALE_Z, TREES.MODEL_TRANSLATE_Z] = Math.random()*3+1 [TREES.MODEL_SCALE_X, TREES.MODEL_SCALE_Y, TREES.MODEL_SCALE_Z, TREES.MODEL_TRANSLATE_Z] = Math.random()*3+1

Assuming I understand you correctly, you'll want to first create the value, then store the same one into all four places:假设我理解正确,您首先要创建该值,然后将相同的值存储到所有四个位置:

random_value = Math.random()*3+1

TREES.MODEL_SCALE_X = random_value
TREES.MODEL_SCALE_Y = random_value
TREES.MODEL_SCALE_Z = random_value
TREES.MODEL_TRANSLATE_Z = random_value

Also, in Python it's actually the random module which you'd want, not "Math".此外,在 Python 中,它实际上是您想要的random模块,而不是“数学”。 So the following would actually be what you want in Python:因此,以下实际上是您在 Python 中想要的:

import random
random_value = random.random()*3+1

TREES.MODEL_SCALE_X = random_value
TREES.MODEL_SCALE_Y = random_value
TREES.MODEL_SCALE_Z = random_value
TREES.MODEL_TRANSLATE_Z = random_value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM