Skip to main content

Hi, when opening fbx in FME, I see a property with a description of the material in the geometry parts (pay attention to the line highlighted with a marker) 

FME has a python interpreter, with its own classes and functions.
I have already pulled out the coordinates of the points, in the code below

import fme
import fmeobjects


FeatureProcessor class (object):


def __init__(self):

passes

entering def (self, feature):


all_geom = function.getGeometry()

first_part = all_geom.getPartAt(0)

if type(first_part) == fmeobjects.FMEMesh:
meshs = first_part.getAsMultiSurface()


vertices_list = first_part.getVertices()
textur_coord_list = first_part.getTextureCoordinates()
textur_length = len(textur_coord_list)

if textur_length > 0:

for trian_mesh in first_part:

ver_index = trian_mesh.getVertexIndices()
textur_index = trian_mesh.getVertexNormalIndices()


newFeature = fmeobjects.FMEFeature()


pnt1 = vertices_listtver_indexx0]]
pnt1_t = textur_coord_list textur_index 0]]

newFeature.setAttribute('X1',pnt110])
newFeature.setAttribute('Y1',pnt111])
newFeature.setAttribute('Z1',pnt112])
newFeature.setAttribute('U1',pnt1_tt0])
newFeature.setAttribute('V1',pnt1_tt1])

pnt2 = vertices_listtver_indexx1]]
pnt2_t = textur_coord_list textur_indexx1]]

newFeature.setAttribute('X2',pnt220])
newFeature.setAttribute('Y2',pnt221])
newFeature.setAttribute('Z2',pnt222])
newFeature.setAttribute('U2',pnt2_tt0])
newFeature.setAttribute('V2',pnt2_tt1])


pnt3 = vertices_listtver_indexx2]]
pnt3_t = textur_coord_listttextur_indexx2]]

newFeature.setAttribute('X3',pnt330])
newFeature.setAttribute('Y3',pnt331])
newFeature.setAttribute('Z3',pnt332])
newFeature.setAttribute('U3',pnt3_tt0])
newFeature.setAttribute('V3',pnt3_tt1])

newFeature.setAttribute('geometry_name', feature.getAttribute('_geometry_name'))
newFeature.setAttribute('path_rootname', feature.getAttribute('path_rootname'))
newFeature.setAttribute ('appearance')

self.pyoutput(newFeature)
more:
newFeature_error = fmeobjects.FMEFeature()
newFeature_error.setAttribute('error_geometry', feature.getAttribute('_geometry_name'))
self.pyoutput(newFeature_error)


def close(self):

passes

def process_group(self):

passes

But it doesn't work for Appearance.
Judging by the help – appearance, this is part of the geometry. If you fall into the appearance class, then it should be a separate class, but how to pull it into separate variables is not described in the help

When referring to any function, it says that there are no such attributes.
I tried to refer to the feature unit itself, and to all its parts
-all_geometry
-first_part
-mesh
-trian_mesh

Please help with changing the code to extract attributes from the Front Appearance Preference line marked in the image above.

PS The FBX file for the test is attached.

Hello, @muzhnasto.

We do have an AppearanceExtractor transformer that is more simple and may suffice your use case.

If you have gone by it and it does not suffice your use case, I can gladly give you some pointers for your python script.

Thanks!


Hello, @muzhnasto.

We do have an AppearanceExtractor transformer that is more simple and may suffice your use case.

If you have gone by it and it does not suffice your use case, I can gladly give you some pointers for your python script.

Thanks!

hi, how use python set texturecoord?


Hey, @charry.

Looking at the FME Python Documentation, setTextureCoordinate() doesn't exist. If you haven't checked them out yet, the fmeobjects.FMEMesh.appendTextureCoordinate() and fmeobjects.FMEMesh.appendTextureCoordinates() functions are available.

There is a transformer called TextureCoordinateSetter. If you haven't checked that out yet, that may suffice what you are trying to achieve.

Other than those resources, it would be helpful if you could elaborate more on what you are trying to achieve here. I’m more than glad to guide you.

Another option is searching if there is a similar question to what you're trying to accomplish in the Community. If not, you could create a question thread via Start a post on the navigation bar, and folks on the Community and other Safers can gladly help!


Hi, @AliAtSafe.

Appearance Extractor extracts information from a single object. However, I need to extract information for each individual polygon and do so through Python, as objects consist of multiple polygons and it is necessary to extract additional attributes for each one. Processing these polygons as separate entities (splitting them, etc.) would be very time-consuming for a computer. Therefore, I am seeking assistance in writing code in Python to accomplish this task.


Reply