2
$\begingroup$

I am doing the scripting of some design processes for an add-on. What I am about to ask seems like a simple thing to do, but ......

I have two .py scripts:

The first asks the user to define a range of dimensions using an input window in blender, this then produces that basic geometry in blender based on the values input.

The second script then asks the user to input a variety of data to distort the original geometry in various ways. As part of this manipulation, I would like to access the data that was input through the first script, for use in the second script.

In my mind this seems like an easy thing to do as the data is there in Blender somewhere, but I cannot find a way of accessing it. I have been searching through lots of forums looking for a similar question, but I cannot seem to find the answer I am looking for.

Does anyone know how to access user input from input windows that are not created in the current script?

Thanks Steve

$\endgroup$
3
  • $\begingroup$ Is the generated geometry itself sufficient data or do you want to access the actual parameters the user input? In the second case, answers would depend on how much data was created by the first script. A reasonable number of parameters could be custom properties attached to bpy.type.Object. Fill them in in the first script and be able to access it in the second. Otherwise you might want to create an external representation that you could save in a custom text data block. Let us know more about the nature of the data and we can suggest approaches. $\endgroup$ Jan 8, 2022 at 16:15
  • 1
    $\begingroup$ Hi Marty, Thanks for the comment. Sorry, I took a break and went for a walk. When I got back I found two solutions that both worked. See my answer to my own question below. $\endgroup$ Jan 8, 2022 at 17:04
  • $\begingroup$ Always glad to see someone find their own answers. $\endgroup$ Jan 8, 2022 at 17:22

1 Answer 1

2
$\begingroup$

OK, after a bit of a break and thinking about it again, I found two possible solutions.

  1. Using a Blender approach: in the first script I can assign data using

     self.geoObj.data['diameter'] = self.dia_inp
    

    Where geoObj is the name of my object, 'diameter' is variable name I want to access later and dia_inp is the input made by the user.

    In my second script I can then use the following to get that data from the active object

      dia_inp = bpy.context.active_object.data['diameter']
    
  2. Using a python approach: I created a new python file that essentially contains global variables, say gvars.py which contains dummy versions of all the variables I want from the user input. I import this into the first script and then use the following to update the dummy variables:

     gvars.diameter = dia_inp
    

    In the second script I also import gvars and then access the updated value using

     dia_inp = gvars.diameter
    

Both solutions seem to work, I feel that the Blender approach (1) is probably safer.

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .