Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Check parameter validity (C++)

Check parameter validity (C++)

chrisdawlud
Enthusiast Enthusiast
527 Views
2 Replies
Message 1 of 3

Check parameter validity (C++)

chrisdawlud
Enthusiast
Enthusiast

Hi,

I want to check whether a scene object has it's "texmap" parameter set or not. I couldn't find API for that so I came up with the following, but it doesn't work:

 

 

 

 

auto object = lightNode->GetObjectRef();

if (isVrayLight(object))
{
	auto pb = static_cast<IParamBlock2*>(GetReference(0));
	
	Texmap* texmap;
	auto success = pb->GetValueByName(TSTR{ "texmap" }, TimeValue{}, texmap, Interval{});
	// if (!Texmap) doesn't work properly either
	if (!success) {}

// I also tried this:

auto object = lightNode->GetObjectRef();

if (isVrayLight(object))
{
	auto pb = static_cast<IParamBlock2*>(GetReference(0));
	
	auto texmap = pb->GetTexmap(34, TimeValue{}, Interval{});
	if (!texmap) {}

 

 

 

The second example involves hardcoding the ID (in this case, 34, which I deducted from within maxscript by running getpropnames $). Does anyone know a better way to get it or should I just stick to GetValueByName()?

 

0 Likes
528 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor

If you want to check a specific property, you must specify a name and find it by name.

If you are looking for all the properties of TYPE_TEXMAP, you can go through all and find by property type.

 

When you say "it doesn't work", what does not work?

0 Likes
Message 3 of 3

chrisdawlud
Enthusiast
Enthusiast

The problem was I forgot to call GetReference() specifically on 'object' rather than this->GetReference() so it works as expected now. I just wasn't sure if this approach is correct.

 

I also found out that I can obtain the ID like this:

auto texmap_id = object_pb->GetDesc()->IndextoID(
	object_pb->GetDesc()->NameToIndex(TSTR"texmap" }));
object_pb->ReleaseDesc();

 

0 Likes