SendModelingCommand, MCData result array question
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/04/2012 at 11:07, xxxxxxxx wrote:
OK thanks.
This advice contradicts the sticky posted here about always using Get&Set parameter() instead of BaseContainers. So I try not to use BaseContainers as much as possible.
But I realize in programming there are no absolutes. And sometimes you have no choice.Still. I suppose this could maybe confuse some people.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/04/2012 at 04:27, xxxxxxxx wrote:
i have replaced the smc with my own code , so i do not need this specific example anymore,
but i still would really like to know, how we are supposed to use MDATA_Options. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/04/2012 at 07:11, xxxxxxxx wrote:
MDATA_Options doesn't exist in the SDK. It's just a group of all container IDs for modeling commands.
In the documentation IDs are grouped for better indexing. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/04/2012 at 08:06, xxxxxxxx wrote:
so, we have to write the ids from MData_Options into the bc of the respective tool to
use them or aren't we allowed to use the ids at all ? sorry, i still don't get it. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/04/2012 at 00:11, xxxxxxxx wrote:
Originally posted by xxxxxxxx
so, we have to write the ids from MData_Options into the bc of the respective tool to
use them or aren't we allowed to use the ids at all ? sorry, i still don't get it.Yes you can use the IDs listed in MData_Options. For example MDATA_CURRENTSTATETOOBJECT_INHERITANCE, MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION and MDATA_CURRENTSTATETOOBJECT_NOGENERATE for MCOMMAND_CURRENTSTATETOOBJECT.
And the IDs from MData_Options are placed under their related command in SendModelingCommand() documentation.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/04/2012 at 03:34, xxxxxxxx wrote:
hi,
thanks for the clarification. that i wasn't able to set the vectors for the knife tool is just a limitation
of the knifetool ?(i am aware that my orginal apporach to write these vectors into a seperate bc,
which i tried to write into the id MDATA_KNIFE_ was wrong, i also tried to write these values directly
into the ModellingCommandData bc.) -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/04/2012 at 08:54, xxxxxxxx wrote:
Originally posted by xxxxxxxx
that i wasn't able to set the vectors for the knife tool is just a limitation
of the knifetool ?I contacted the developers on this.
-
On 29/01/2013 at 07:23, xxxxxxxx wrote:
Hi,
A recent thread made me remember that I got some months ago an interesting code snippet from the developers that was showing how to send a knife modeling command.
What's most important to understand is: MDATA_KNIFE_P1, MDATA_KNIFE_P2, MDATA_KNIFE_V1 and MDATA_KNIFE_V2 have to be given in world space.
For this purpose we can use the handy conversion methods of BaseView (parent class of BaseDraw). In the example we call BaseView.SW() to convert screen space coordinates to world space.
v1 and v2 are basically vectors showing away from the camera (and going through p1/p2). v1 % v2 build the normal of the cutting plane.The following example will show how to cut the selected spline just in the middle of the view:
import c4d from c4d import utils def SplineCutter(doc, op, bd, x1, y1, x2, y2, bSelect) : p1 = bd.SW(c4d.Vector(x1, y1, 0.0)) v1 = bd.SW(c4d.Vector(x1, y1, 100.0)) - p1 p2 = bd.SW(c4d.Vector(x2, y2, 0.0)) v2 = bd.SW(c4d.Vector(x2, y2, 100.0)) - p2 bc = c4d.BaseContainer() bc.SetVector(c4d.MDATA_KNIFE_P1, p1) bc.SetVector(c4d.MDATA_KNIFE_P2, p2) bc.SetVector(c4d.MDATA_KNIFE_V1, v1) bc.SetVector(c4d.MDATA_KNIFE_V2, v2) bc.SetBool(c4d.MDATA_KNIFE_RESTRICT, False) bc.SetBool(c4d.MDATA_KNIFE_SELECTCUTS, bSelect) if op is not None and op.CheckType(c4d.Ospline) : utils.SendModelingCommand(command = c4d.MCOMMAND_KNIFE, list = [op], bc = bc, doc = doc, flags = c4d.MODELINGCOMMANDFLAGS_CREATEUNDO) c4d.EventAdd() def main() : bd = doc.GetActiveBaseDraw() frame = bd.GetFrame() middleX = (frame['cr']-frame['cl'])/2 SplineCutter(doc, op, bd, middleX, frame['ct'], middleX, frame['cb'], True) if __name__=='__main__': main()
You can then modify the call to SplineCutter() in main() to use other coordinates from the mouse, a tool etc. You can also 'play' with others MDATA_KNIFE_ options.
EDIT: Fixed the code.
-
On 29/01/2013 at 09:17, xxxxxxxx wrote:
hey, thanks for the clarification
-
On 29/01/2013 at 11:32, xxxxxxxx wrote:
Hello Yannick
Please correct your code(if you tested it?!), if you want to post right example for help:
1. console displays: AttributeError: 'c4d.SplineObject' object has no attribute 'IsInstanceOf'
2. even seems code was wrote from scratch : bc.SetVector( c4d., v2) - > bc.SetVector(c4d.MDATA_KNIFE_V2, v2)Any way, data from bc for SendModelingCommand, should be based on bd data?... For example
c4d.ID_MODELING_POINT_ADD_TOOL at bc[c4d.MDATA_ADDPOINT_POINT] = gm.Mul(poly_center(op, i)) # vector data -
On 30/01/2013 at 00:17, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Please correct your code(if you tested it?!), if you want to post right example for help:
1. console displays: AttributeError: 'c4d.SplineObject' object has no attribute 'IsInstanceOf'Yes, I tested the code (of course!) but I ported the code from C++ and used a recent version of CINEMA where C4DAtom.IsInstanceOf() is defined. With R14.034 and older releases we have to call C4DAtom.CheckType() instead.
Originally posted by xxxxxxxx
2. even seems code was wrote from scratch : bc.SetVector( c4d., v2) - bc.SetVector(c4d.MDATA_KNIFE_V2, v2)
This is an edition 'cut and copy' mistake when I wrote my post. I should have checked it and its embedded code before posting.
Originally posted by xxxxxxxx
Any way, data from bc for SendModelingCommand, should be based on bd data?... For example
c4d.ID_MODELING_POINT_ADD_TOOL at bc[c4d.MDATA_ADDPOINT_POINT] = gm.Mul(poly_center(op, i)) # vector dataThe knife example only uses the BaseDraw to convert points from screen to world coordinates. This is not needed for the setup of all modeling commands.
-
On 30/01/2013 at 10:32, xxxxxxxx wrote:
Hello.
Thank you for clarification.