FSXA Blender python script for custom colour picker [SOLVED]

#1
Hi,

I would like to get some info if anybody can help me create some custom color picker script which will be positioned under Material panel in blender. I want to position it under the red line as in the image below:

V9nxw.jpg


Code sample from other source:
Code:
import bpy

class DetailColor(bpy.types.Panel):
    bl_label = "Detail Color"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "material"

def draw(self, context):
        self.layout.prop(context.scene, "DetailColor", text='Detail Color')
        row = layout.row()
        # Material Property Added
        mat = context.active_object.active_material
        row.prop(mat, "DetailColor", text="")

def register():
    bpy.utils.register_class(DetailColor)
    bpy.types.Scene.DetailColor = bpy.props.FloatVectorProperty(
                                 name = "DetailColor",
                                 subtype = "COLOR",
                                 size = 4,
                                 min = 0.0,
                                 max = 1.0,
                                 default = (1.0,1.0,1.0,1.0)
                                 )

def unregister():
    bpy.utils.unregister_class(DetailColor)
  
if __name__ == "__main__":
    register()
The above sample code doesn't help to position below the red line. Hope someone could identify what is the issue in the codes there.

Thank you,
Manochvarma Raman
 
#3
Hi @Dave_W,

Thank you for the suggestions. I have tried blender stackecxchange but it seems no one willing to help to specifically explain how to position it at our desired location. I will try blender aritist forum and see how is the response.
 
#4
I'm sorry.

I didn't look closely enough at your screenshot to see that the code you want is for the Blender2FSXP3D toolset. It is highly unlikely that you would get help on those forums for something like that.

Note to self: engage brain before putting mouth in gear :banghead:
 
#5
Hi Dave_W,

That's ok :D. After trial and error, I was able to find out the code.

I think the toolset is almost complete now. Just a small proeprty detail is not showing up when loading the .MDL file into MCX. I have asked Arno to check it out. Once he found it, will release the toolset that is to be version 0.9.4
 

Ronald

Resource contributor
#8
I have tried Blender Stackecxchange but it seems no one willing to help to specifically explain how to position it at our desired location.
A - My experience, By patient and learn to ask your question in the exact right format, first, since the Blender.StackExchange is very strict about it.
The StackExchange community is (highly professional and) a very different-type-of-community then most average Blender forums on the internet.

TIP: The better and more compact your question is formulated, the sooner you will have the right answer to continue:
Here are some tips to get you started, formatting your (future) questions:
- https://blender.stackexchange.com/tour
Since... In the end you will get the high-quality answers you'll need to get your Blender-Python challenge done Manochvarma


B - I would like to add to Dave_W's list:
- Blender (developer-level and end-users) IRC-chatrooms.
- Blender developers (e)mailing list.
On this Blender Wiki page you can read you can contact the developers (and other experienced end-users) directly:
- https://wiki.blender.org/index.php/Dev:Doc/Contact

This thread on the Blender Artists forum explains how to ask question in the Blender community
- https://blenderartists.org/forum/sh...-Developers-Invite-quot-Ask-us-Anything!-quot

I hope this information is helpful for you, so you know where to ask which type-of-blender-related questions in the future.


Before that I need to study python first.
Here are some official Blender places to get started:
- https://docs.blender.org/api/2.79a/
- https://docs.blender.org/api/248PythonDoc/
- https://docs.blender.org/api/

Blender Artists - Python API scripting forum:
- https://blenderartists.org/forum/forumdisplay.php?11-Python-Support[/url Other websites on Blender and Python: - https://docs.python.org/3/tutorial/ - [URL]http://blenderscripting.blogspot.nl/
- https://en.wikibooks.org/wiki/Blend...anced_Tutorials/Python_Scripting/Introduction
- https://sites.google.com/site/satishgoda/blender/learningblender25/tutorial-scripting-panels

Youtube videos on this subject
- https://www.youtube.com/results?sea...search_query=blender+python+api+custom+panels

BONUS: Free downloadable Blender Python API E-book:
- https://smtebooks.com/Downloads/5809/the-blender-python-api-pdf

Now you are ready to:wizard: unleash your inner Python....:eek:
 
Last edited:
#9
Hi @Ronald

Thank you for the links. It was very helpful indeed.

I was able to find a solution for the question as below:
Python:
 Material.fsxm_DetailColor = FloatVectorProperty(
                                 name = "DetailColor",
                                 subtype = "COLOR",
                                 size = 4,
                                 min = 0.0,
                                 max = 1.0,
                                 default = (1.0,1.0,1.0,1.0)
                                 )
Thank you.
 

F747fly

Resource contributor
#10
May I just ask why you want this? I'm assuming you want it to be like 3DS MAX where every new material gets a seperate colour, so when you export the materials don't become one? I personally found this is not very desirable. Firstly, you can use the same colour as many times as you like as long as the materials have atleast one setting (be it a texture set or an FSX parameter) different. Secondly, baking AO or other maps is a lot easier when using 1 colours (I personally make all my materials pure white, it works best for me).

Either way, glad you figured it out!
 
#11
May I just ask why you want this? I'm assuming you want it to be like 3DS MAX where every new material gets a seperate colour, so when you export the materials don't become one? I personally found this is not very desirable. Firstly, you can use the same colour as many times as you like as long as the materials have atleast one setting (be it a texture set or an FSX parameter) different. Secondly, baking AO or other maps is a lot easier when using 1 colours (I personally make all my materials pure white, it works best for me).

Either way, glad you figured it out!
Hi Frits,
I was looking it for implementing P3D materials parameters into Blender2FSX/P3D toolset.
 
Top