Derive value from a function

Derive value from a function

roberto_infanti
Contributor Contributor
291 Views
4 Replies
Message 1 of 5

Derive value from a function

roberto_infanti
Contributor
Contributor

I have a solid.ipt (cubic for exsample). On one face, I apply an offset of 1 mm. on another 2mm, another 5mm, etc. I would like only faces that are offset by 5 to turn red. Thanks

0 Likes
Accepted solutions (1)
292 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

This might work in some simple cases. But in more complex models it might fail. Give it a go.

Dim doc As PartDocument = ThisDoc.Document

Dim features = doc.ComponentDefinition.Features.ThickenFeatures

Dim asset As Asset = doc.Assets.Add(
			AssetTypeEnum.kAssetTypeAppearance,
			"Generic",
			"appearances")
Dim uColor As ColorAssetValue = asset.Item("generic_diffuse")
uColor.Value = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

For Each item As ThickenFeature In features
	Dim distance = item.Distance.Value

	If (distance = 0.5) Then
		For Each outputFace As Face In item.Faces
			outputFace.Appearance = asset
		Next
	End If
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 5

roberto_infanti
Contributor
Contributor

Perfect!!!! Thankyou !!!!!  Just one question. Why is it that if I set inventor in mm and if the thicknen is equal to 5 mm, on the macro I am forced to write 0.5 (x/10) ?

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

Inventor uses what they call "Database" units. The "Database" unit for a length is "Cm". Therefore you need to divide by 10.

You can find more info in my blog post on that subject: "Parameter, Document and Database Units"

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

roberto_infanti
Contributor
Contributor

Thanks, I get it. You're really kind! Thank you. I'll start reading your blog! You're really good. Congratulations

0 Likes