Scripting the implementation of BTrace add-on #63688

Closed
opened 2019-04-17 20:52:38 +02:00 by Rahul Shankarrao Nalawade · 4 comments

System Information
Operating system: Ubuntu 16.04 LTS (64-bit)
Graphics card: Intel® UHD Graphics 620 (Kabylake GT2)
Processor: Intel® Core™ i5-8250U CPU @ 1.60GHz × 8

Blender Version
Worked: 2.79b Date: 2018-03-22 14:10 Hash: f4dc9f9d68b

Short description of error
Unable to script the implementation of BTrace addon

Exact steps for others to reproduce the error

  1. Import Several meshes
  2. And run this following script:
import bpy
import os

- PRECONDITION: The segmented meshes should be all in the following path 
- 'segmented_model' directory.
- ------------------------------------------------------------------------------
- A. IMPORTING ALL MESHES

- ------------------------------------------------------------------------------
- B. EXTRACTING THE CENTERS OF EACH MESH

# Selecting everything
bpy.ops.object.select_all(action='SELECT')
# Select origins of each mesh
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')

- ------------------------------------------------------------------------------
- C. FINDING SPLINE

# Selecting the BTrace window -> Objects Connect
bpy.data.window_managers["WinMan"].curve_tracer.btrace_toolmenu = 'tool_objectsConnect'
bpy.ops.group.create(name="Btrace")

- Executing 'Run' button: 
- Iteratively execting 3 commands for each mesh
for i in range(0, N):
    bpy.ops.object.editmode_toggle()
    bpy.ops.object.hook_add_selob()
    bpy.ops.object.editmode_toggle()
#endFor

bpy.ops.object.select_all(action='DESELECT')    
bpy.ops.object.group_link(group='Btrace')
bpy.ops.object.btobjectsconnect() # >> ERROR <<

- -----------------------------------------------------------------------------
- D. EXPORTING THE GENERATED CURVE

bpy.ops.object.select_all(action='DESELECT') 
N = len(bpy.data.objects) - 1 # all the mesh + 1 curve in bpy.data.objects

# Using the name of last object as the suffix of the name of our curve: 
name = bpy.data.objects[N].name # get it's name

model_directory = "/home/rahul/SomeDirectory/"
bb_directory = model_directory + "Model-BB/"

stl_path = os.path.join(bb_directory, name + '.Spline.stl')

bpy.ops.object.select_all(action='DESELECT') 

# NOTE**: the curve is at index i = 0.  

# Now, deleting first N meshes
for i in range(0,N):
    bpy.data.objects[1].select = True # always select the second mesh**
    bpy.ops.object.delete() # and delete the mesh
#endFor

# Into the EDIT mode
bpy.ops.object.editmode_toggle()
# Select all points
bpy.ops.curve.select_all(action='SELECT')
# Smoothify
bpy.ops.curve.handle_type_set(type='AUTOMATIC')
bpy.ops.object.editmode_toggle() # back in to OBJECT mode

# Exporting the mesh (curve)
bpy.ops.export_mesh.stl(filepath=stl_path)

#------------------------------------------------------------------------------```

Based on the default startup or an attached .blend file (as simple as possible). 

Please see my [query](https://blender.stackexchange.com/questions/136103/scripting-the-generation-of-a-curve-from-the-set-of-mesh-centers-drawn-using-btr) for more details. 
**System Information** Operating system: Ubuntu 16.04 LTS (64-bit) Graphics card: Intel® UHD Graphics 620 (Kabylake GT2) Processor: Intel® Core™ i5-8250U CPU @ 1.60GHz × 8 **Blender Version** Worked: 2.79b Date: 2018-03-22 14:10 Hash: f4dc9f9d68b **Short description of error** Unable to script the implementation of BTrace addon **Exact steps for others to reproduce the error** 1. Import Several meshes 2. And run this following script: ``` import bpy import os - PRECONDITION: The segmented meshes should be all in the following path - 'segmented_model' directory. - ------------------------------------------------------------------------------ - A. IMPORTING ALL MESHES - ------------------------------------------------------------------------------ - B. EXTRACTING THE CENTERS OF EACH MESH # Selecting everything bpy.ops.object.select_all(action='SELECT') # Select origins of each mesh bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') - ------------------------------------------------------------------------------ - C. FINDING SPLINE # Selecting the BTrace window -> Objects Connect bpy.data.window_managers["WinMan"].curve_tracer.btrace_toolmenu = 'tool_objectsConnect' bpy.ops.group.create(name="Btrace") - Executing 'Run' button: - Iteratively execting 3 commands for each mesh for i in range(0, N): bpy.ops.object.editmode_toggle() bpy.ops.object.hook_add_selob() bpy.ops.object.editmode_toggle() #endFor bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.group_link(group='Btrace') bpy.ops.object.btobjectsconnect() # >> ERROR << - ----------------------------------------------------------------------------- - D. EXPORTING THE GENERATED CURVE bpy.ops.object.select_all(action='DESELECT') N = len(bpy.data.objects) - 1 # all the mesh + 1 curve in bpy.data.objects # Using the name of last object as the suffix of the name of our curve: name = bpy.data.objects[N].name # get it's name model_directory = "/home/rahul/SomeDirectory/" bb_directory = model_directory + "Model-BB/" stl_path = os.path.join(bb_directory, name + '.Spline.stl') bpy.ops.object.select_all(action='DESELECT') # NOTE**: the curve is at index i = 0. # Now, deleting first N meshes for i in range(0,N): bpy.data.objects[1].select = True # always select the second mesh** bpy.ops.object.delete() # and delete the mesh #endFor # Into the EDIT mode bpy.ops.object.editmode_toggle() # Select all points bpy.ops.curve.select_all(action='SELECT') # Smoothify bpy.ops.curve.handle_type_set(type='AUTOMATIC') bpy.ops.object.editmode_toggle() # back in to OBJECT mode # Exporting the mesh (curve) bpy.ops.export_mesh.stl(filepath=stl_path) #------------------------------------------------------------------------------``` Based on the default startup or an attached .blend file (as simple as possible). Please see my [query](https://blender.stackexchange.com/questions/136103/scripting-the-generation-of-a-curve-from-the-set-of-mesh-centers-drawn-using-btr) for more details.

Added subscriber: @Rahul1947

Added subscriber: @Rahul1947
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Brendon Murphy self-assigned this 2019-05-26 02:47:34 +02:00
Member

hi, closing as Invalid. This tracker is for bugs in Blender addons. Your stack exchange question appears to have been answered, please continue discussion there if you need to.
Thanks

hi, closing as Invalid. This tracker is for bugs in Blender addons. Your stack exchange question appears to have been answered, please continue discussion there if you need to. Thanks
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#63688
No description provided.