In Rhino.NET I color mesh face vertices, but faces get no color

I’m working in C# with Rhino.Net SDK building commands for a plug-in.

I’m trying to color mesh faces by coloring the face vertices.

This sample code attempts to draw a simple three face mesh with the “middle” face in red orange and the other two in green. The three face mesh appears fine, but the faces have no color:

On3dmObjectAttributes obatts = new On3dmObjectAttributes();
obatts.SetColorSource(IOn.object_color_source.color_from_object);

rusted = OnColor.FromColor(Color.OrangeRed);

OnMesh threeFaceMesh = new OnMesh(3, 12, false, false);

for (int ii = 0; ii < 12; ii++) xw = threeFaceMesh.SetVertex(ii, vertx[ii]);
for (int ii = 0; ii < 12; ii++) threeFaceMesh.m_C[ii] = OnColor.FromColor(Color.Green);
threeFaceMesh.m_C[2] = rusted;
threeFaceMesh.m_C[3] = rusted;
threeFaceMesh.m_C[5] = rusted;
threeFaceMesh.m_C[4] = rusted;

threeFaceMesh.SetQuad(0, 0, 1, 3, 2);
threeFaceMesh.SetQuad(1, 2, 3, 6, 7);
threeFaceMesh.SetQuad(2, 9, 8, 5, 4);

context.m_doc.AddMeshObject(threeFaceMesh, obatts);
context.m_doc.Redraw();

Any hints?

Thank you,

Peter Schwenn

by the way, the vertices are from a preamble

		On3dPoint[] vertx = new On3dPoint[12];

		vertx[0] = new On3dPoint(0,0,0);
		vertx[1] = new On3dPoint(0,1,0);
		vertx[2] = new On3dPoint(1,0,0);
		vertx[3] = new On3dPoint(1,1,0);
		vertx[4] = new On3dPoint(1,0,1);
		vertx[5] = new On3dPoint(1,1,1);
		vertx[6] = new On3dPoint(2,1,0);
		vertx[7] = new On3dPoint(2,0,0);
		vertx[8] = new On3dPoint(1,1,.001);
		vertx[9] = new On3dPoint(1,0,.001);
		vertx[10] = new On3dPoint(1,0,0);
		vertx[11] = new On3dPoint(1,1,0);

I found the answer to my own question: m_C array is not automatically allocated the same size as m_V. It must be appended to to grow to the desired size.

So for example:
for (int ii = 0; ii < 12; ii++) xw = threeFaceMesh.SetVertex(ii, vertx[ii]);
for (int ii = 0; ii < 12; ii++) threeFaceMesh.m_C.Append(OnColor.FromColor(Color.Green));
threeFaceMesh.m_C[2] = rusted;
threeFaceMesh.m_C[3] = rusted;
threeFaceMesh.m_C[6] = rusted;
threeFaceMesh.m_C[7] = rusted;

Thank you. Peter Schwenn

Hi Peter

seeing this, I am thinking whether you are aware of the reduction in availability of the .Net SDK in Rhino 6+, and the suggested usage of RhinoCommon in (upcoming) Rhino 6. The old and much-beloved .Net SDK will be less important there (more details here). So just think about it now, if possible.

Thanks,

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

005_8E474BDB5BEEB647BA4A71A38C4AF00460D57C21FRD1VEXCDB02Pco
Content-Type: multipart/alternative;
boundary=“000_8E474BDB5BEEB647BA4A71A38C4AF00460D57C21FRD1VEXCDB02Pco

000_8E474BDB5BEEB647BA4A71A38C4AF00460D57C21FRD1VEXCDB02Pco
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Designation: Non-Finmeccanica
Dear Giulio,

Thanks for the heads up.

We are transitioning to RhinoCommon, but we have a customer who may not fol=
low, so we have a prototype plugin for them which uses Rhino.NET.

By the way, when is Rhino6 coming approximately?

Thanks again,

Peter Schwenn

Senior Naval Architect/Software Developer

DRS Technologies, Inc.
Advanced Marine Technology Center
160 Sallitt Drive, Suite 200, Stevensville, MD 21666
Tel: 410.604.8007 Fax: 410.643.5370
pschwenn@drs-ds.commailto:pschwenn@drs-ds.com
www.drs-ds.comhttp://www.drs-ds.com/
www.orca3d.comhttp://www.orca3d.com/

[Description: Description: Description: C:\Users\amims\AppData\Local\Temp\F=
inal-New-DRS-Color.png]
This communication is intended only for use by the addressee(s) named herei=
n and may contain business proprietary and/or legally privileged informatio=
n. If you are not the intended recipient of this e-mail, you are hereby not=
ified that any dissemination, distribution, disclosure or copying of this e=
-mail and its contents is strictly prohibited. If you have received this e-=
mail in error, kindly notify the sender by replying to this message. In add=
ition, please permanently delete the message and any attachments without co=
pying or disclosing the contents. Thank you for your cooperation.

From: piac [mailto:steve@mcneel.com]
Sent: Tuesday, November 12, 2013 5:46 AM
To: Schwenn, Peter
Subject: [McNeel Forum] new reply to your post in ‘In Rhino.NET I color mes=
h face vertices, but faces get no color’

[Image removed by sender.]

piachttp://discourse.mcneel.com/users/piac
November 12

Hi Peter

seeing this, I am thinking whether you are aware of the reduction in availa=
bility of the .Net SDK in Rhino 6+, and the suggested usage of RhinoCommon =
in (upcoming) Rhino 6. The old and much-beloved .Net SDK will be less impor=
tant there (more details here<http://www.grasshopper3d.com/forum/topics/rhi=
no-dotnet-will-be-discontinued>). So just think about it now, if possible.

Thanks,

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

To respond, reply to this email or visit http://discourse.mcneel.com/t/in-r=
hino-net-i-color-mesh-face-vertices-but-faces-get-no-color/3648/3 in your b=
rowser.


Thanks, this makes sense.

By the way, when is Rhino6 coming approximately?

I do not know about this, sorry, and I do not think this has been decided, yet.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

A post was split to a new topic: Developing rhino4