Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2011 at 04:42, xxxxxxxx wrote:
User Information: Cinema 4D Version: Platform: Language(s) : C.O.F.F.E.E ; C++ ; PYTHON ;
--------- Hi there,
I post this in the SDK Help Subforum, because I am sure, if someone knows a way to solve my Problem in C++ I can transfer it to Python.
What I want is to merge 2 Polygonobjects into one. If you know how to do it, you actually don't need to understand my Code. If not, I hope C++'ers can understand it.
It actually works, but some points are connected with the the other objects. And theire axes are resetted , but I know how to fix this, and I will do this later.
def SetAllPoints(op,points) : if op is None: return False if points is None: return False cnt = op.GetPointCount() for i in xrange(cnt) : op.SetPoint(i,points[i]) op.Message(c4d.MSG_UPDATE) def SetAllPolygons(op,polys) : if op is None: return False if polys is None: return False cnt = op.GetPolygonCount() for i in xrange(cnt) : op.SetPolygon(i,polys[i]) op.Message(c4d.MSG_UPDATE) def MakeEditable(op) : if (not op) : return if (op.CheckType(c4d.Opolygon) == True) : return op op = [op.GetClone()] doc = c4d.documents.BaseDocument() doc.InsertObject(op[0],None,None) op = c4d.utils.SendModelingCommand( command = c4d.MCOMMAND_MAKEEDITABLE, list = op, doc = doc ) return op[0] def MergeLists(lst1,lst2) : for line in lst2: lst1.append(line) return lst1 def MergePolygonObjects(obj1,obj2) : op = c4d.BaseObject(c4d.Opolygon) obj1 = MakeEditable(obj1) obj2 = MakeEditable(obj2) op.ResizeObject(obj1.GetPointCount()+obj2.GetPointCount(),obj1.GetPolygonCount()+obj2.GetPolygonCount()) SetAllPoints(op,MergeLists(obj1.GetAllPoints(),obj2.GetAllPoints())) SetAllPolygons(op,MergeLists(obj1.GetAllPolygons(),obj2.GetAllPolygons())) return op
Thanks in Advance, nux
On 09/03/2011 at 05:03, xxxxxxxx wrote:
hi there, you have to remap the vertex-indices of the second polygonobject. Adding an offset obj1.GetPointCount() to each vertex index in the polygon array of the second one should do it. greetz
On 09/03/2011 at 08:12, xxxxxxxx wrote:
You could use SendModelingCommand(MCOMMAND_JOIN, ...). The only caveat is that you will need to put the editable objects under a Null object and pass the Null object in with the ModelingCommandData. Best to make clones to work with.
On 09/03/2011 at 09:03, xxxxxxxx wrote:
Thanks, that should work. Haha, didn't think about this !
Still got some problems, postet in the Python Subforum. https://plugincafe.maxon.net/topic/5572/5593_mcommandjoin
Cheers, nux