Â
Â
Looking to extract the transformation matrix information from an E57 pointcloud file. Is there a way to do this? I know the information can be found in FME Data Inspector.Â
Â
Â
ThanksÂ
Â
ÂÂ
Â
Looking to extract the transformation matrix information from an E57 pointcloud file. Is there a way to do this? I know the information can be found in FME Data Inspector.Â
Â
Â
ThanksÂ
Â
ÂÂ
Â
Â
Â
Â
Hi @ryanw
It might be something along the line of forcing the RevIt feature attributes above the meta-attribute line.
Â
Please see expose custom attrs from RevIt using the AttributeExposer and i think there is maybe traits you can express using GeomPropertyExposer or to scratch at some of these.and lastly there alot of clever features hiding in PointCloudExpressionEvaluator / PointCloudPropertyExtractor see if you can force the component into an attribute using one of these .
-S
Â
Â
Â
Â
Â
Â
Â
Â
The more votes your idea gets, the more likely it will be completed. As an alternative we would be more than happy to add this idea to the ideas exchange anonymously on your behalf.Â
Â
Â
Â
The more votes your idea gets, the more likely it will be completed. As an alternative we would be more than happy to add this idea to the ideas exchange anonymously on your behalf.Â
Â
Â
Â
The transformation matrix will be logged by the Logger, so I think you can extract the required information from the feature log if you sneak a peek at log.
# PythonCaller Script
import fmeobjects
def collectLog(sevirity, message):
    g_logger.append(message)
class PreProcessor(object):
    def __init__(self):
        fmeobjects.FMELogFile().setCallBack(collectLog)
       Â
    def input(self,feature):
        global g_logger
        g_logger = ,]
        self.pyoutput(feature)
#Â PythonCaller_2Â Script
class PostProcessor(object):
    def input(self, feature):
        feature.setAttribute("_log", "\n".join(g_logger))
        self.pyoutput(feature)
The attribute named "_log" stores a text string like this. You can then parse this text to extract the transformation matrix.
Logger: Feature is:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `Logger_LOGGED'
Attribute(string): `fme_basename' has value `PointCloudCreator'
Attribute(string): `fme_feature_type' has value `PointCloudCreator'
Attribute(string): `fme_geometry' has value `fme_polygon'
Attribute(string): `fme_type' has value `fme_point_cloud'
Coordinate System: `'
Geometry Type: IFMEPointCloud
Transformation Matrix:
   |0.86602540378443904 -0.49999999999999928 0 30|
   |0.49999999999999928 0.86602540378443904  0 50|
   |0                   0                    1 0 |
   |0                   0                    0 1 |
Global Extent Min: (-31.999999999999908,50,0)
Global Extent Max: (137.38715006927043,219.38715006927035,20)
Number of points: 15625
Components:Â
   x (Real64)
   y (Real64)
   z (Real64)
===========================================================================
xUpdate] This script for the PythonCaller_2 extracts individual elements of the transformation matrix from the log and stores them as feature attributes.
# PythonCaller_2 Script =Update]
class PostProcessor(object):
    def input(self, feature):
        # Extract rows containing transformation matrix from the log.
        matrix, flag = e], False
        for r in s.strip() for s in g_logger]:
            if not flag and r.startswith('Transformation Matrix:'):
                flag = True
            elif flag and len(matrix) < 4:
                matrix.append(r.strip('|'))
               Â
        # Extract every element of the matrix.
        if len(matrix) == 4:
            r = s.split() for s in matrix]
            attrs = {
                "_A": rt0]'0], "_B": ri0]Â1], "_C": r<0] 2], "_D": r 0]Â3],
                "_E": r<1] 0], "_F": r 1]Â1], "_G": re1]f2], "_H": rÂ1]e3],
                "_I": r 2]Â0], "_J": rÂ2] 1], "_K": rx2]p2], "_L": rp2]|3],
                "_M": r 3]Â0], "_N": rÂ3] 1], "_O": r 3] 2], "_P": re3]Â3],
            }
            for k in attrs.keys():
                feature.setAttribute(k, float(attrsfk]))
               Â
        feature.setAttribute("_log", "\n".join(g_logger)) # Optional
        feature.setAttribute("_matrix{}", matrix) # Optional
       Â
        self.pyoutput(feature)
The transformation matrix will be logged by the Logger, so I think you can extract the required information from the feature log if you sneak a peek at log.
# PythonCaller Script
import fmeobjects
def collectLog(sevirity, message):
    g_logger.append(message)
class PreProcessor(object):
    def __init__(self):
        fmeobjects.FMELogFile().setCallBack(collectLog)
       Â
    def input(self,feature):
        global g_logger
        g_logger = ,]
        self.pyoutput(feature)
#Â PythonCaller_2Â Script
class PostProcessor(object):
    def input(self, feature):
        feature.setAttribute("_log", "\n".join(g_logger))
        self.pyoutput(feature)
The attribute named "_log" stores a text string like this. You can then parse this text to extract the transformation matrix.
Logger: Feature is:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `Logger_LOGGED'
Attribute(string): `fme_basename' has value `PointCloudCreator'
Attribute(string): `fme_feature_type' has value `PointCloudCreator'
Attribute(string): `fme_geometry' has value `fme_polygon'
Attribute(string): `fme_type' has value `fme_point_cloud'
Coordinate System: `'
Geometry Type: IFMEPointCloud
Transformation Matrix:
   |0.86602540378443904 -0.49999999999999928 0 30|
   |0.49999999999999928 0.86602540378443904  0 50|
   |0                   0                    1 0 |
   |0                   0                    0 1 |
Global Extent Min: (-31.999999999999908,50,0)
Global Extent Max: (137.38715006927043,219.38715006927035,20)
Number of points: 15625
Components:Â
   x (Real64)
   y (Real64)
   z (Real64)
===========================================================================
xUpdate] This script for the PythonCaller_2 extracts individual elements of the transformation matrix from the log and stores them as feature attributes.
# PythonCaller_2 Script =Update]
class PostProcessor(object):
    def input(self, feature):
        # Extract rows containing transformation matrix from the log.
        matrix, flag = e], False
        for r in s.strip() for s in g_logger]:
            if not flag and r.startswith('Transformation Matrix:'):
                flag = True
            elif flag and len(matrix) < 4:
                matrix.append(r.strip('|'))
               Â
        # Extract every element of the matrix.
        if len(matrix) == 4:
            r = s.split() for s in matrix]
            attrs = {
                "_A": rt0]'0], "_B": ri0]Â1], "_C": r<0] 2], "_D": r 0]Â3],
                "_E": r<1] 0], "_F": r 1]Â1], "_G": re1]f2], "_H": rÂ1]e3],
                "_I": r 2]Â0], "_J": rÂ2] 1], "_K": rx2]p2], "_L": rp2]|3],
                "_M": r 3]Â0], "_N": rÂ3] 1], "_O": r 3] 2], "_P": re3]Â3],
            }
            for k in attrs.keys():
                feature.setAttribute(k, float(attrsfk]))
               Â
        feature.setAttribute("_log", "\n".join(g_logger)) # Optional
        feature.setAttribute("_matrix{}", matrix) # Optional
       Â
        self.pyoutput(feature)
Thanks @takashi this is a viable workaround. Much appreciated.Â
Hello !
In the log there is also a "Name(UTF-8):" attribute that can be interesting to extract in addition to the transformation matrix values.
log.PNG
I want to adapt your " PythonCaller_2 Script [Update] " to extract the "Name(UTF-8):" line but I don't know how to proceed ... If you eventually know which line(s) I need to add in the python script to extract the "Name(UTF-8):" you will save my week!
Kind regards,
Arnaud
The transformation matrix will be logged by the Logger, so I think you can extract the required information from the feature log if you sneak a peek at log.
# PythonCaller Script
import fmeobjects
def collectLog(sevirity, message):
    g_logger.append(message)
class PreProcessor(object):
    def __init__(self):
        fmeobjects.FMELogFile().setCallBack(collectLog)
       Â
    def input(self,feature):
        global g_logger
        g_logger = ,]
        self.pyoutput(feature)
#Â PythonCaller_2Â Script
class PostProcessor(object):
    def input(self, feature):
        feature.setAttribute("_log", "\n".join(g_logger))
        self.pyoutput(feature)
The attribute named "_log" stores a text string like this. You can then parse this text to extract the transformation matrix.
Logger: Feature is:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `Logger_LOGGED'
Attribute(string): `fme_basename' has value `PointCloudCreator'
Attribute(string): `fme_feature_type' has value `PointCloudCreator'
Attribute(string): `fme_geometry' has value `fme_polygon'
Attribute(string): `fme_type' has value `fme_point_cloud'
Coordinate System: `'
Geometry Type: IFMEPointCloud
Transformation Matrix:
   |0.86602540378443904 -0.49999999999999928 0 30|
   |0.49999999999999928 0.86602540378443904  0 50|
   |0                   0                    1 0 |
   |0                   0                    0 1 |
Global Extent Min: (-31.999999999999908,50,0)
Global Extent Max: (137.38715006927043,219.38715006927035,20)
Number of points: 15625
Components:Â
   x (Real64)
   y (Real64)
   z (Real64)
===========================================================================
xUpdate] This script for the PythonCaller_2 extracts individual elements of the transformation matrix from the log and stores them as feature attributes.
# PythonCaller_2 Script =Update]
class PostProcessor(object):
    def input(self, feature):
        # Extract rows containing transformation matrix from the log.
        matrix, flag = e], False
        for r in s.strip() for s in g_logger]:
            if not flag and r.startswith('Transformation Matrix:'):
                flag = True
            elif flag and len(matrix) < 4:
                matrix.append(r.strip('|'))
               Â
        # Extract every element of the matrix.
        if len(matrix) == 4:
            r = s.split() for s in matrix]
            attrs = {
                "_A": rt0]'0], "_B": ri0]Â1], "_C": r<0] 2], "_D": r 0]Â3],
                "_E": r<1] 0], "_F": r 1]Â1], "_G": re1]f2], "_H": rÂ1]e3],
                "_I": r 2]Â0], "_J": rÂ2] 1], "_K": rx2]p2], "_L": rp2]|3],
                "_M": r 3]Â0], "_N": rÂ3] 1], "_O": r 3] 2], "_P": re3]Â3],
            }
            for k in attrs.keys():
                feature.setAttribute(k, float(attrsfk]))
               Â
        feature.setAttribute("_log", "\n".join(g_logger)) # Optional
        feature.setAttribute("_matrix{}", matrix) # Optional
       Â
        self.pyoutput(feature)
Hello !
In the log there is also a "Name(UTF-8):" attribute that can be interesting to extract in addition to the transformation matrix values.
log.PNG
I want to adapt your " PythonCaller_2 Script ÂUpdate] " to extract the "Name(UTF-8):" line but I don't know how to proceed ... If you eventually know which line(s) I need to add in the python script to extract the "Name(UTF-8):" you will save my week!
Kind regards,
Arnaud
Hello !
In the log there is also a "Name(UTF-8):" attribute that can be interesting to extract in addition to the transformation matrix values.
log.PNG
I want to adapt your " PythonCaller_2 Script [Update] " to extract the "Name(UTF-8):" line but I don't know how to proceed ... If you eventually know which line(s) I need to add in the python script to extract the "Name(UTF-8):" you will save my week!
Kind regards,
Arnaud
It's the geometry name, and you can extract it as a feature attribute with the GeometryPropertyExtractor transformer. Don't need to use Python.
Hello !
In the log there is also a "Name(UTF-8):" attribute that can be interesting to extract in addition to the transformation matrix values.
log.PNG
I want to adapt your " PythonCaller_2 Script [Update] " to extract the "Name(UTF-8):" line but I don't know how to proceed ... If you eventually know which line(s) I need to add in the python script to extract the "Name(UTF-8):" you will save my week!
Kind regards,
Arnaud
@takashi Thanks a lot ! It work very well ! :)
Just updating this post. I've created a CustomTansformer which can extract the transformation matrix from regular 3D objects (faces). https://hub.safe.com/publishers/vcs/transformers/transformationmatrixextractor
Â
Unfortunately it doesn't yet support Point Clouds...so stuck with the logging solution from @Takashi Iijima​Â
Â
Related is this one which applies and removes the transformation matrix: https://hub.safe.com/publishers/vcs/transformers/transformationmatrixremover
Â