Create and display polygon object
-
On 24/05/2013 at 09:18, xxxxxxxx wrote:
I want to create a polygon object, but it won't display (or create, I don't know)
Anything I should change to make it work?if (doc.SearchObject('R_Leg') == None) : global R_Leg R_Leg = c4d.BaseObject(Opolygon) R_Leg.__init__(12, 10) doc.InsertObject(R_Leg) R_Leg.SetPoint(0, (-18.0, 2.0, -7.0)) R_Leg.SetPoint(1, (-18.0, 21.0, -7.0)) R_Leg.SetPoint(2, (-18.0, 40.0, -7.0)) R_Leg.SetPoint(3, (-4.0, 2.0, -7.0)) R_Leg.SetPoint(4, (-4.0, 21.0, -7.0)) R_Leg.SetPoint(5, (-4.0, 40.0, -7.0)) R_Leg.SetPoint(6, (-4.0, 2.0, 7.0)) R_Leg.SetPoint(7, (-4.0, 21.0, 7.0)) R_Leg.SetPoint(8, (-4.0, 40.0, 7.0)) R_Leg.SetPoint(9, (-18.0, 2.0, 7.0)) R_Leg.SetPoint(10, (-18.0, 21.0, 7.0)) R_Leg.SetPoint(11, (-18.0, 40.0, 7.0)) R_Leg_Polygon_0.__init__(t_a = 0, t_b = 3, t_c = 4, t_d = 1) R_Leg.SetPolygon(0, R_Leg_Polygon_0) R_Leg_Polygon_1.__init__(t_a = 1, t_b = 2, t_c = 5, t_d = 4) R_Leg.SetPolygon(1, R_Leg_Polygon_1) R_Leg_Polygon_2.__init__(t_a = 3, t_b = 4, t_c = 7, t_d = 6) R_Leg.SetPolygon(2, R_Leg_Polygon_2) R_Leg_Polygon_3.__init__(t_a = 4, t_b = 5, t_c = 8, t_d = 7) R_Leg.SetPolygon(3, R_Leg_Polygon_3) R_Leg_Polygon_4.__init__(t_a = 6, t_b = 7, t_c = 10, t_d = 9) R_Leg.SetPolygon(4, R_Leg_Polygon_4) R_Leg_Polygon_5.__init__(t_a = 7, t_b = 8, t_c = 11, t_d = 10) R_Leg.SetPolygon(5, R_Leg_Polygon_5) R_Leg_Polygon_6.__init__(t_a = 9, t_b = 10, t_c = 1, t_d = 0) R_Leg.SetPolygon(6, R_Leg_Polygon_6) R_Leg_Polygon_7.__init__(t_a = 10, t_b = 11, t_c = 2, t_d = 1) R_Leg.SetPolygon(7, R_Leg_Polygon_7) R_Leg_Polygon_8.__init__(t_a = 0, t_b = 3, t_c = 6, t_d = 9) R_Leg.SetPolygon(8, R_Leg_Polygon_8) R_Leg_Polygon_9.__init__(t_a = 2, t_b = 5, t_c = 8, t_d = 11) R_Leg.SetPolygon(9, R_Leg_Polygon_9) R_Leg.Message(c4d.MSG_UPDATE) R_Leg.SetName('R_Leg') c4d.EventAdd()
Greetz
-
On 24/05/2013 at 09:24, xxxxxxxx wrote:
Maybe I can help you if you describe your problem. It's not that I can't see it from your code, but
please show at least some effort. Do you really expect that everyone that is willing to help you, is
at the same time willing to analyze your code and guess your problem? There are about dozens
of possibilites why your code fails or does not work the way you want it. I can see some of them
directly from your code, others rely on the context that you are not explaining. And I'm not going to
list up all those possibilities just because you were to lazy to explain your problem, nor show the
error message or describe the desired/undesired result. -
On 24/05/2013 at 09:34, xxxxxxxx wrote:
Ok, your right. I'll try to remember to allways explain it properly
But in fact, I don't know how to further describe it.
It's just a creation of a polygon-object (with the creation of some CPolygons) that won't display in Cinema 4D.
-
On 24/05/2013 at 09:47, xxxxxxxx wrote:
Are you getting an error message? It looks like you should, since I don't see where you have
set any value to R_Leg_Polygon_0. From what I see in your code, that, and other variables, should
not exist and therefore result in an exception. -
On 24/05/2013 at 09:57, xxxxxxxx wrote:
you do init your cpoly object multiple times. that is not a good idea. i am not
sure how cinema 4d does treat the cpoly instanced passed to SetPolygon(),
but reusing the same instance seems to be a bad idea. also calling important
methods explicitly is a bit awkward.R_Leg = c4d.BaseObject(Opolygon) R_Leg.__init__(12, 10) better : myobj = c4d.PolygonObject(12,10) R_Leg_Polygon_0.__init__(t_a = 0, t_b = 3, t_c = 4, t_d = 1) R_Leg.SetPolygon(0, R_Leg_Polygon_0) better: R_Leg.SetPolygon(0, c4d.CPolygon(0,3,4,1))
-
On 24/05/2013 at 10:12, xxxxxxxx wrote:
CPolygon is stored by value in the PolygonObject, so reusing it should not be a problem. But I don't
see him reusing it anyway. There is R_Leg_Polygon_0 to R_Leg_Polygon_9, littledevil.I agree with you on the bad style using __init__() directly. He should really be doing it the way you
have shown. -
On 24/05/2013 at 10:15, xxxxxxxx wrote:
ah, you are right, got confused by wall of text
-
On 26/05/2013 at 08:46, xxxxxxxx wrote:
Thanks guys!