Armory Props: How to use? Where are informations/documentations?

I suppose one can pass variables from Blender to Armory here.
Armory_Props

How does this work? Is there an example?

I want to pass a sun position as initial value from the Blender Add-On sun path to the world_sun_direction example.

Can I access variables in the above Properties list with (Blender) drivers?
How can I access these variables in a trait?

If all this works, could you have Armory calculate a new value for a certain time (date + time) in Blender (the Python class already exists there) and then use it in Armory?

  • Armory ZUI input field(s) date and time
  • Armory trait calls a blender python script with these input values
  • Armory gets return value from blender
  • Armory sets the new sun direction

Development of the solution part 1:

Blender


given properties for object: Plane

prop_my_string = bpy.data.objects[‘Plane’].arm_propertylist[0]. string_prop

Armory3D

zicklag UiScript.hx I guess that’s the solution.

You need to create a trait for the object that owns the property.

image

Result:

1 Like

Also, you might like to know that you can also add properties to Traits that can be set in the Blender UI. For example, from Armory’s bundled traits:

class FollowCamera extends iron.Trait {


	@prop
	var target:String;


	@prop
	var lerp:Bool = true;


	@prop
	var lerpSpeed:Float = 0.1;

The @prop annotation makes Armory add the target, lerp, and lerpSpeed settings to the trait panel and the trait will get access to the values set in the UI through those variables.

image

For the opposite direction there is this example script_properties.

Access in Blender (assuming trait belongs to Object Camera):

target_name = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[0].name
target_value = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[0].value
lerp_name = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[1].name
lerp_value = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[1].value
lerp_speed = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[2].name
lerp_speed_value = bpy.data.objects[‘Camera’].arm_traitlist[0].arm_traitpropslist[2].value

The values of the variables are strings.

1 Like

I googled that you can use python directly from Haxe: How to execute external Python script with a program coded in Haxe?

For this you use externs.

When an Armory game is run, it doesn’t have access to any Python environment. Technically you could still get it to run python scripts on the system, but that requires that Python is installed on the system and is in the path. You can use externs to interact with Python programs in Haxe when you compile Haxe to Python, but Armory doesn’t compile it’s Haxe code to Python, it compiles to JavaScript or C.

Python can be used perfectly well for stuff inside of Blender like the Armory addon does, but once the game is exported and run, Python can’t do anything.