4
$\begingroup$

I have a bunch of locations from a group of objects and I want to turn it into the vertices of a new objects with no edge connections.

$\endgroup$
6
$\begingroup$

enter image description here

In the .gif I invoke the Pie Menu with the W key.

enter image description here

The important part in this setup is the small loop that takes a list of objects and returns their locations in a new list. This basic setup is pretty common all kinds of animation nodes trees.

Extra notes:

The python equivalent to this loop would be:

# Long Version
locations = []
for object in objectList:
    location = object.location
    locations.append(location)

# More Pythonic Version
locations = [object.location for object in objectList]

The core of the addon translates for your node tree into python code that looks like this:

 def main(loop_iterator_0):
     global _frame_9pg, _enabled_jfa
     loop_generator_output_0 = []
     loop_zipped_list = list(zip(loop_iterator_0))
     loop_iterations = len(loop_zipped_list)
     for current_loop_index, (loop_iterator_element_0, ) in enumerate(loop_zipped_list): 
         # Node: 'NodeTree' - 'Object Transforms Input'
         try:
             _location_9pg = loop_iterator_element_0.location
         except:
             _location_9pg = mathutils.Vector((0, 0, 0))
             _rotation_9pg = mathutils.Euler((0, 0, 0))
             _scale_9pg = mathutils.Vector((0, 0, 0))
             _quaternion_9pg = mathutils.Quaternion((1, 0, 0, 0))
         if _enabled_jfa:
             loop_generator_output_0.append(_location_9pg)
         pass
     return loop_generator_output_0
$\endgroup$
3
$\begingroup$

Not too familiar with animation nodes, but you can do this with a short python script:

import bpy

groupName = 'Group'              ## <== change group name if needed
g = bpy.data.groups[groupName]  

locations = [ o.location for o in g.objects ]

name = 'MeshFromGroup'
mesh = bpy.data.meshes.new( name = name )

o = bpy.data.objects.new(name, mesh)
o.location = (0,0,0) # place at object origin
bpy.context.scene.objects.link( o )

mesh.from_pydata( locations, [], [] )

Just copy this into a new textfile in the text editor, change the name of the group if it's not "Group", and press the "Run Script" button.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.