On 21/06/2018 at 03:48, xxxxxxxx wrote:
Actually, STITCHANDSEW have a different implementation compared to other ModelingCommand.
First of all, you need to pass a document and the first object.
Then additionally in MDATA_STITCHANDSEW_BC1, you have to set point id you actually want to stitch
Here is the structure of this container (which is currently not documented).
bc = count of points you want to stitch for the first selection
bc[10 to 9999] = point ID
bc = count of points you want to stitch for the second selection
bc[10010 and more] = point ID
Points will be connected in the same order you fill the BaseContainer.
For example bc = 10 and bc = 20, you will connect the point ID 10 from the first obj to the point ID 20 of the second obj (which can be the same than the first object).
So here an example which connects selected points.
def GetPointIdSelected(obj) :
if not obj:
ptIds = list()
ptCnt = obj.GetPointCount()
bs = obj.GetPointS()
for index, selected in enumerate(bs.GetAll(ptCnt)) :
if not selected:
def main() :
obj1 = doc.SearchObject("Cube")
obj2 = doc.SearchObject("Cube.1")
l1 = GetPointIdSelected(obj1)
l2 = GetPointIdSelected(obj2)
con = c4d.BaseContainer()
con = len(l1) # cnt of ptn selected in first object
con = len(l2) # cnt of ptn selected in second object
# assign pt ID for first object and make sure to not overwrite con
for i in xrange(min(len(l1), 9989)) :
con[10+i] = l1[i]
# assign pt ID for second object
for i in xrange(len(l2)) :
con[10010+i] = l2[i]
bc = c4d.BaseContainer()
# Make sure to define [obj1] and doc
c4d.utils.SendModelingCommand(c4d.ID_MODELING_STITCHANDSEW_TOOL, [obj1], c4d.MODELINGCOMMANDMODE_EDGESELECTION, bc, doc=doc)