Page MenuHome

Scripting the implementation of BTrace add-on
Closed, InvalidPublic

Description

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 for more details.

Details

Type
Bug

Event Timeline

Brendon Murphy (meta-androcto) closed this task as Invalid.

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