SendModelingCommand Bridge. How? [SOLVED]

On 02/05/2015 at 13:01, xxxxxxxx wrote:

Is there any way to perform a Bridge command in code?
I have two meshes. I can easily select the polygons I want to connect.
But, how can I define the point of mesh #1 that should connect to a point in mesh #2 ?

On 03/05/2015 at 04:32, xxxxxxxx wrote:

It is stated in the SDK to look into the toolbridge.h file to check out the parameters.
This toolbridge.h file contains this:
**
#ifndef _ToolBridge_H_
#define _ToolBridge_H_

enum
{

MDATA_BRIDGE_ELEMENT1                    =1100, //LONG
MDATA_BRIDGE_ELEMENT2                    =1101, //LONG
MDATA_BRIDGE_ELEMENT3                    =1102, //LONG
MDATA_BRIDGE_ELEMENT4                    =1103, //LONG
MDATA_BRIDGE_OBJINDEX1                   =1104, //LONG
MDATA_BRIDGE_OBJINDEX2                   =1105, //LONG
MDATA_BRIDGE_OBJINDEX3                   =1106, //LONG
MDATA_BRIDGE_OBJINDEX4                   =1107, //LONG
MDATA_BRIDGE_DELETE                      =1108, //BOOL
MDATA_BRIDGE_ISO                   =1109, //BOOL
MDATA_BRIDGE_
};

#endif
**

I know what the MDATA_BRIDGE_DELETE is but what exactly are those:
**
MDATA_BRIDGE_ELEMENT1
MDATA_BRIDGE_ELEMENT2
MDATA_BRIDGE_ELEMENT3
MDATA_BRIDGE_ELEMENT4
MDATA_BRIDGE_OBJINDEX1
MDATA_BRIDGE_OBJINDEX2
MDATA_BRIDGE_OBJINDEX3
MDATA_BRIDGE_OBJINDEX4
MDATA_BRIDGE_ISO
**
?

On 04/05/2015 at 00:22, xxxxxxxx wrote:

Hello,

the exact use the Bridge tool depends on what exactly you want to do with it and the context in which it is used (point, poly mode etc.)

So if you want to create a bridge between the selected polygons of two polygon objects the code could look like this:

  
settings = c4d.BaseContainer()  
  
# polygon objects                   
settings[c4d.MDATA_BRIDGE_OBJINDEX1] = poly1  
settings[c4d.MDATA_BRIDGE_OBJINDEX2] = poly2    
  
# the selected polygons  
settings[c4d.MDATA_BRIDGE_ELEMENT1] = 1  
settings[c4d.MDATA_BRIDGE_ELEMENT2] = 3   
  
# point indices to define the first edge  
settings[c4d.MDATA_BRIDGE_ELEMENT3] = 4  
settings[c4d.MDATA_BRIDGE_ELEMENT4] = 6   
  
commandid = c4d.ID_MODELING_BRIDGE_TOOL  
objdoc = doc  
flags = c4d.MODELINGCOMMANDFLAGS_CREATEUNDO  
mode = c4d.MODELINGCOMMANDMODE_POLYGONSELECTION   
  
c4d.utils.SendModelingCommand(command=commandid, list=[poly1,poly2], doc=objdoc, flags=flags, bc = settings, mode=mode)  
                                                       
c4d.EventAdd()  

best wishes,
Sebastian

On 04/05/2015 at 01:29, xxxxxxxx wrote:

That is exactly what I was needing, Sebastian. Thank you.
I will try it as soon as I get home.
By the way, what is the MDATA_BRIDGE_ISO for?

p.s. The SDK would benefit from some additional information about some commands. Just sending the reader to .h file is not enough.

On 04/05/2015 at 12:10, xxxxxxxx wrote:

Damn, it is not working 😞
Here is my code:
**
bc=c4d.BaseContainer()

the_trunk is a polygonal object created inside my code

bc[c4d.MDATA_BRIDGE_OBJINDEX1] = the_trunk

result[0> is a polygonal object that results from a previous SendModelingCommand

bc[c4d.MDATA_BRIDGE_OBJINDEX2] = result[0]

selection is the polygon index to bridge from, in the trunk

bc[c4d.MDATA_BRIDGE_ELEMENT1] = selection

the second to last polygon from result[0>

bc[c4d.MDATA_BRIDGE_ELEMENT2] = polygon_count-1

idx1[index1> points to the point in the_trunk that is nearer (this point is part of the polygon that is referenced in selection

bc[c4d.MDATA_BRIDGE_ELEMENT3] = idx1[index1]

idx2[index2> points to the point in result[0> that is nearer (this point is part of the polygon that is referenced by polygon_count-1

bc[c4d.MDATA_BRIDGE_ELEMENT4] = idx2[index2]
bc[c4d.MDATA_BRIDGE_DELETE] = True

select the polygons in the_trunk and result[0>

trunk_select.DeselectAll()
trunk_select.Select(selection)

branch_select.DeselectAll()
branch_select.Select(polygon_count-1)

worked=utils.SendModelingCommand(command=c4d.ID_MODELING_BRIDGE_TOOL,list=[the_trunk,result[0]],mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,bc=bc,doc=the_trunk.GetDocument())

this ALWAYS prints False 😞

print worked
**

What could I be doing wrong?

On 06/05/2015 at 05:57, xxxxxxxx wrote:

I finally managed to make it work (sort of), by using IsolateObjects to create a new document where I perform the Bridge command.
Now I have a new problem, but I will create a new post for it. 🙂