How do I get to the Repeat value of a texture map in a material via the API

I want to get the Repeat factor for a bitmap texture. This shows up in the Mapping section of the UX.

Assuming the usage of RhinoCommon you can use RenderTexture.GetRepeat() .

Paraphrased something like:

RhinoObject yourObject = GetSomehow();
RenderMaterial rm = yourObject.RenderMaterial;
var diffchan = rm.TextureChildSlotName(RenderMaterial.StandardChildSlots.Diffuse);
var difftex = rm.FindChild(diffchan) as RenderTexture;
Vector3d repeat = difftex.GetRepeat();

And if I am using C++ and I have a CRhinoMaterial object … how would I get to the Repeat value?

@johnc - can you help with this?

Hi,

Here is some C++ code that should achieve what you need. It assumes you have a valid Rhino Document pointer handy and that the bitmap texture is in the first texture slot (‘Color’):

 // Find the Render Material associated with the Rhino Material.
 const auto* pMaterial = pDoc->Contents().Find(rhinoMat.RdkMaterialInstanceId());
 if (nullptr != pMaterial)
 {
 	// Find the bitmap texture.
 	// This assumes the texture is in the bitmap ('Color') slot.
	const auto* pChild = pMaterial->FindChild(CS_MAT_BITMAP_TEXTURE);
 	const auto* pTexture = dynamic_cast<const CRhRdkTexture*>(pChild);
 	if (nullptr != pTexture)
 	{
 		// Get the repeat value from the texture.
 		const auto repeat = pTexture->Repeat();
		...
 	}
 }

Regards,

John

Very nice … yes, I have a valid Rhino Document pointer handy.

This makes sense and yes, I only want to do this when there is a bitmap assigned.

Many thanks!