phaenotyp

Table of Contents

  • Intro
  • Getting started
  • Install
  • Update
  • Remove
  • GUI
  • Variables
  • Scripting
  • Examples
phaenotyp
Docs » scripting

Scripting

You can interact with Phänotyp via scripting. Experienced users can use this feature already when studying the Guithub of Phänotyp. This is a minimal example of accessing the functions via the text editor in Blender 3D directly. When structure, supports and profiles are set correctly, this script is doing a simple single thread analysis followed by three sectional optimizations.

  1. import bpy
  2. from phaenotyp import operators
  3.  
  4. # run single fram analysis
  5. operators.calculate_single_frame()
  6.  
  7. # run utilization optimization for 3 times
  8. for i in range(3):
  9. operators.optimize_utilization()

You can achieve the same result when running this operations separately.

  1. import bpy
  2. from phaenotyp import basics, calculation, geometry
  3.  
  4. # get basic variables
  5. scene = bpy.context.scene
  6. frame = scene.frame_current
  7. members = scene["<Phaenotyp>"]["members"]
  8.  
  9. # calculate new properties for each member
  10. geometry.update_members_pre()
  11.  
  12. # create a truss object for PyNite
  13. truss = calculation.prepare_fea()
  14.  
  15. # run singlethread and get results at this frame
  16. feas = calculation.run_st(truss, frame)
  17.  
  18. # wait for it and interweave results to data
  19. calculation.interweave_results(feas, members)
  20.  
  21. # do sectional optimizatoin by utilization for three times
  22. for i in range(3):
  23. # get new diameters for each member
  24. calculation.utilization_sectional()
  25.  
  26. # calculate new properties for each member
  27. geometry.update_members_pre()
  28.  
  29. # created a truss object of PyNite
  30. truss = calculation.prepare_fea()
  31.  
  32. # run singlethread and get results
  33. feas = calculation.run_st(truss, frame)
  34.  
  35. # wait for it and interweave results to data
  36. calculation.interweave_results(feas, members)
  37.  
  38. # calculate new visualization-mesh
  39. geometry.update_members_post()
  40.  
  41. # update view
  42. basics.view_vertex_colors()
  43.  
  44. # print the first members axial value at the first frame at its start
  45. print(members['0']['axial']['1'][0])
Previous Next