Hello,
please see the attached image. A wood appearance was assigned to a face.
How can I obtain the default mapping direction from this / any plane face?
I need to know the direction where the texture is rotated by 0 degree.
Thanks
Christoph
It's probably buried inside the appearance settings.
Run the following VBA code and analyze the result:
Public Sub GetAppearanceSettingsToFile() Dim doc As PartDocument Set doc = ThisApplication.ActiveDocument Dim appearance As asset 'Set appearance = doc.Assets.item("Rot_Transparent") Set appearance = doc.ActiveAppearance Dim f As Integer f = FreeFile() Open "C:\Temp\" & appearance.DisplayName & ".txt" For Output As #f Print #f, "Appearance Name: " & appearance.DisplayName Dim value As AssetValue For Each value In appearance PrintAssetValueToFile f, value, 5 Next Close #f End Sub
Private Function ColorToString(InColor As color) As String
ColorToString = "[" & InColor.Red & ", " & InColor.Green & ", " & InColor.Blue & ", " & InColor.Opacity & "]"
End Function
Private Sub PrintAssetValueToFile( _ ByRef f As Integer, _ ByRef inValue As AssetValue, _ ByRef indent As Long) Dim indentChars As String indentChars = space(indent) Print #f, indentChars & "Value" Print #f, indentChars & " DisplayName: " & inValue.DisplayName Print #f, indentChars & " Name: " & inValue.name Print #f, indentChars & " IsReadOnly: " & inValue.IsReadOnly Select Case inValue.ValueType Case kAssetValueTextureType Print #f, indentChars & " Type: Texture" Dim textureValue As TextureAssetValue Set textureValue = inValue Dim texture As AssetTexture Set texture = textureValue.value Select Case texture.TextureType Case kTextureTypeBitmap Print #f, indentChars & " TextureType: kTextureTypeBitmap" Case kTextureTypeChecker Print #f, indentChars & " TextureType: kTextureTypeChecker" Case kTextureTypeGradient Print #f, indentChars & " TextureType: kTextureTypeGradient" Case kTextureTypeMarble Print #f, indentChars & " TextureType: kTextureTypeMarble" Case kTextureTypeNoise Print #f, indentChars & " TextureType: kTextureTypeNoise" Case kTextureTypeSpeckle Print #f, indentChars & " TextureType: kTextureTypeSpeckle" Case kTextureTypeTile Print #f, indentChars & " TextureType: kTextureTypeTile" Case kTextureTypeUnknown Print #f, indentChars & " TextureType: kTextureTypeUnknown" Case kTextureTypeWave Print #f, indentChars & " TextureType: kTextureTypeWave" Case kTextureTypeWood Print #f, indentChars & " TextureType: kTextureTypeWood" Case Else Print #f, indentChars & " TextureType: Unexpected type returned" End Select Print #f, indentChars & " Values" Dim textureSubValue As AssetValue For Each textureSubValue In texture Call PrintAssetValue(textureSubValue, indent + 4) Next Case kAssetValueTypeBoolean Print #f, indentChars & " Type: Boolean" Dim booleanValue As BooleanAssetValue Set booleanValue = inValue Print #f, indentChars & " Value: " & booleanValue.value Case kAssetValueTypeChoice Print #f, indentChars & " Type: Choice" Dim choiceValue As ChoiceAssetValue Set choiceValue = inValue Print #f, indentChars & " Value: " & choiceValue.value Dim names() As String Dim choices() As String Call choiceValue.GetChoices(names, choices) Print #f, indentChars & " Choices:" Dim i As Integer For i = 0 To UBound(names) Print #f, indentChars & " " & names(i) & ", " & choices(i) Next Case kAssetValueTypeColor Print #f, indentChars & " Type: Color" Dim colorValue As ColorAssetValue Set colorValue = inValue Print #f, indentChars & " HasConnectedTexture: " & colorValue.HasConnectedTexture Print #f, indentChars & " HasMultipleValues: " & colorValue.HasMultipleValues If Not colorValue.HasMultipleValues Then Print #f, indentChars & " Color: " & ColorToString(colorValue.value) Else Print #f, indentChars & " Colors" Dim colors() As color colors = colorValue.Values For i = 0 To UBound(colors) Print #f, indentChars & " Color: " & ColorToString(colors(i)) Next End If Case kAssetValueTypeFilename Print #f, indentChars & " Type: Filename" Dim filenameValue As FilenameAssetValue Set filenameValue = inValue Print #f, indentChars & " Value: " & filenameValue.value Case kAssetValueTypeFloat Print #f, indentChars & " Type: Float" Dim floatValue As FloatAssetValue Set floatValue = inValue Print #f, indentChars & " Value: " & floatValue.value Case kAssetValueTypeInteger Print #f, indentChars & " Type: Integer" Dim integerValue As IntegerAssetValue Set integerValue = inValue Print #f, indentChars & " Value: " & integerValue.value Case kAssetValueTypeReference ' This value type is not currently used in any of the assets. Print #f, indentChars & " Type: Reference" Dim refType As ReferenceAssetValue Set refType = inValue Case kAssetValueTypeString Print #f, indentChars & " Type: String" Dim stringValue As StringAssetValue Set stringValue = inValue Print #f, indentChars & " Value: """ & stringValue.value & """" End Select End Sub
Regards,
Philippe.
You better burry this sample 😉
If I copy and run this api sample it runs into errors. This whole "appearance" and its object model ist weird b*llsh*t. The solution to my question can be found in the Face.Evaluator:
Inventor.SurfaceEvaluator oSrfEvaluator;
oSrfEvaluator = oEbeneFläche.Evaluator;
Inventor.Box2d oParamRange;
oParamRange = oSrfEvaluator.ParamRangeRect;
double[] oPoint1 = new double[2];
double[] oPoint2 = new double[2];
double[] oParams1 = new double[2];
double[] oParams2 = new double[2];
oParams1[0] = oParamRange.MinPoint.X; // "bottom left"
oParams1[1] = oParamRange.MinPoint.Y;
oParams2[0] = oParamRange.MaxPoint.X; // "bottom right"
oParams2[1] = oParamRange.MinPoint.Y;
oSrfEvaluator.GetPointAtParam(ref oParams1, ref oPoint1);
oSrfEvaluator.GetPointAtParam(ref oParams2, ref oPoint2);
// local X Axis is default direction of texture:
//
Inventor.Vector oXAxis;
oXAxis = oTG.CreateVector(
oPoint2[0] - oPoint1[0],
oPoint2[1] - oPoint1[1],
oPoint2[2] - oPoint1[2]);
Can't find what you're looking for? Ask the community or share your knowledge.