Question

@FitDGN Factory function usage

  • 3 November 2016
  • 4 replies
  • 2 views

How can I use @FitDGN factory function to fit the view of dgn files to the content. The DGN file is also created using FME from an oracle spatial database.

Is it possible to call it at the shutdown script using python.


4 replies

Userlevel 2
Badge +17

Hi @cnav, I don't know how the @FitDGN function should work, but the syntax is described in this documentation.

FME Factory and Function Documentation | Functions | @FitDGN

You can call an FME function via the Python fmeobjects.FMEFeature.performFunction method. e.g.

# Shutdown Python Script Example: Perform @FitDGN Function
# Assume that the value of a user parameter called "DestDataset_IGDS"
# is an existing DGN (Bentley MicroStation Design V7) file path.
import fme, fmeobjects
fitDGN = '@FitDGN(%s,MASTER,0)' % fme.macroValues['DestDataset_IGDS']
if fme.status:
    xmin, ymin, xmax, ymax = 0.0, 0.0, 100.0, 100.0
    feature = fmeobjects.FMEFeature()
    feature.addCoordinates([(xmin, ymin), (xmax, ymax)])
    feature.performFunction(fitDGN)

Alternatively, you can also use the FMEFunctionCaller transformer to perform the function without writing a script, if you write the DGN file with the FeatureWriter. e.g. 

0684Q00000ArJxWQAV.png

Userlevel 4
Badge +13

Hi @cnav, I don't know how the @FitDGN function should work, but the syntax is described in this documentation.

FME Factory and Function Documentation | Functions | @FitDGN

You can call an FME function via the Python fmeobjects.FMEFeature.performFunction method. e.g.

# Shutdown Python Script Example: Perform @FitDGN Function
# Assume that the value of a user parameter called "DestDataset_IGDS"
# is an existing DGN (Bentley MicroStation Design V7) file path.
import fme, fmeobjects
fitDGN = '@FitDGN(%s,MASTER,0)' % fme.macroValues['DestDataset_IGDS']
if fme.status:
    xmin, ymin, xmax, ymax = 0.0, 0.0, 100.0, 100.0
    feature = fmeobjects.FMEFeature()
    feature.addCoordinates([(xmin, ymin), (xmax, ymax)])
    feature.performFunction(fitDGN)

Alternatively, you can also use the FMEFunctionCaller transformer to perform the function without writing a script, if you write the DGN file with the FeatureWriter. e.g. 

0684Q00000ArJxWQAV.png

Very impressive. I think @FitDGN must be more that 21 years old now.  Surprised and delighted that the little fella can still do some good for folks.  He never made it into a real transformer, but if he had, he'd love to have been downstream from a FeatureWriter...

Hi @takashi I have tried the script as suggested, received the following error.I wonder if this function is for v7 or v8. I am sending output as V8 DGN file? I have checked the output file it contains data as expected and reads properly in Microstation v8 XM edition. Only issue is data is zoomed out to a different location. So a user who opens the file will see black screen instead of the content.

 

FME_END_PYTHON: evaluating python script from string...

@FitDGN: Bounding box of feature after shrinkage is: (363000,2673000),(364000,2673500)

IGDS Coordinate Information:

0 UORs per ` ' and 0 ` ' per ` '

Global origin X: -1.70141183460469e+038 Y: -1.70141183460469e+038 Z: -1.70141183460469e+038

One FME Feature coordinate unit is equal to 0 UORs (Master Units used)

Unable to read element in design file `c:\\temp\\ora2dgn\\B29C.9Q' -- ensure file has not be truncated

A fatal error has occurred. Check the logfile above for details

Error executing string `import fme,fmeobjects

fitDGN="@FitDGN(%s,MASTER,0)" % fme.macroValues['OutputDGN']

if fme.status:

xmin = float(fme.macroValues['X1'])

ymin = float(fme.macroValues['Y1'])

xmax = float(fme.macroValues['X2'])

ymax = float(fme.macroValues['Y2'])

feature=fmeobjects.FMEFeature()

feature.addCoordinates([(xmin,ymin),(xmax,ymax)])

feature.performFunction(fitDGN)

'

FME_END_PYTHON failed to execute provided script

FME_END_PYTHON failure

Program Terminating

Userlevel 2
Badge +17

Hi @takashi I have tried the script as suggested, received the following error.I wonder if this function is for v7 or v8. I am sending output as V8 DGN file? I have checked the output file it contains data as expected and reads properly in Microstation v8 XM edition. Only issue is data is zoomed out to a different location. So a user who opens the file will see black screen instead of the content.

 

FME_END_PYTHON: evaluating python script from string...

@FitDGN: Bounding box of feature after shrinkage is: (363000,2673000),(364000,2673500)

IGDS Coordinate Information:

0 UORs per ` ' and 0 ` ' per ` '

Global origin X: -1.70141183460469e+038 Y: -1.70141183460469e+038 Z: -1.70141183460469e+038

One FME Feature coordinate unit is equal to 0 UORs (Master Units used)

Unable to read element in design file `c:\\temp\\ora2dgn\\B29C.9Q' -- ensure file has not be truncated

A fatal error has occurred. Check the logfile above for details

Error executing string `import fme,fmeobjects

fitDGN="@FitDGN(%s,MASTER,0)" % fme.macroValues['OutputDGN']

if fme.status:

xmin = float(fme.macroValues['X1'])

ymin = float(fme.macroValues['Y1'])

xmax = float(fme.macroValues['X2'])

ymax = float(fme.macroValues['Y2'])

feature=fmeobjects.FMEFeature()

feature.addCoordinates([(xmin,ymin),(xmax,ymax)])

feature.performFunction(fitDGN)

'

FME_END_PYTHON failed to execute provided script

FME_END_PYTHON failure

Program Terminating

The function might not support V8, but I cannot determine that. I would recommend you to contact Safe support if you need to know more.

 

Reply