Category Archives: SmartPlant Foundation (SPF)

SmartPlant Foundation – Database Queries – 3/3

This is part 3 of a 3-part series on how to query the SPF database.

In part 1, I gave an overview of the SPF database model, and showed how to write a simple query to return all objects of a specific type, starting from a given interface. This showed the DATAOBJ (object) and DATAOBJIF (interface) tables.

In part 2 I showed how to get two properties for those objects, using the DATAOBJPR (property) table.

In this post, part 3, I will show how to get a related object via the DATAREL (relationship) table.

Continue reading

SmartPlant Foundation – Database Queries – 2/3

This is part 2 of a 3-part series on how to query the SPF database.

In part 1, I gave an overview of the SPF database model, and showed how to write a simple query to return all objects of a specific type, starting from a given interface. This showed the DATAOBJ (object) and DATAOBJIF (interface) tables.

In this post, I show how to get two properties for those objects, using the DATAOBJPR (property) table.

In part 3, I show how to get a related object via the DATAREL (relationship) table.

Continue reading

SmartPlant Foundation – Database Queries – 1/3

This is part 1 of a 3-part series on how to query the SPF database.

In this post, I give an overview of the SPF database model, and show how to write a simple query to return all objects of a specific type, starting from a given interface. This shows the DATAOBJ (object) and DATAOBJIF (interface) tables.

In part 2, I show how to get two properties for those objects, using the DATAOBJPR (property) table.

In part 3, I show how to get a related object via the DATAREL (relationship) table.

Continue reading

SPF Load Files – UpdateInstruction Reference

Here is a quick reference for the SPF UpdateInstruction loader command. The documentation is scattered across various places in the SPF printable guides, this gathers it all into one place.

<!-- 
IPropValues properties: 
    AddedInterfaces = Tilde-delimited list of interfaces to add to the object.
    PropValues = List of values to assign. Each value to assign is a triplet of
        Interface, Property Name, and Property Value; delimited with the \% pair.
        Multiple triplets are also delimited with the \% character pair, so ensure
        there are 3, 6, 9, etc. values if you split the string on the \% delimiter.
        E.g. <interface>\%<property>\%<value>~<interface>\%<property>\%<value>
IUpdateInstruction properties:
    RemovedInterfaces = Tilde-delimited list of interfaces to remove from the object.
    RemovedProperties = Tilde-delimited list of property names to remove from the object.
-->
    <UpdateInstruction>
        <IObject UID="Update_001" Name="Update_001" />
        <IRefObject RefClass="SPXEngineeringDocMaster" 
            RefUID="5ce5103d-51c0-46c6-a9de-d1065034af57" />
        <IUpdateInstruction 
            RemovedInterfaces="ISPFInterfaceOne~ISPFInterfaceTwo" 
            RemovedProperties="SPFPropNameOne~SPFPropNameTwo" />
        <IPropValues 
            AddedInterfaces="ISPFInterfaceThree~ISPFInterfaceFour" 
            PropValues="IObject\%Description\%New Description\%ISPFInterfaceFive\%ISPFPropNameThree\%New Value for Property Three" />
        <IInstruction/>
    </UpdateInstruction>

 

Comparing XML generated from SPF’s Export Data method

Comparing XML generated by SmartPlant Foundation’s Export Data command can be a pain, as the XML comes out in what seems to be random order.

  • Exported objects (XML elements) are in random order
  • Interfaces in those elements are in random order
  • Properties (XML attributes) in those interfaces are in random order

I have a solution. 🙂

  1. Download Beyond Compare – the best general-pupose compare tool
  2. Download my custom Beyond Compare File Type for SPF XML comparisons

You will have to un-zip this file, then follow the Beyond Compare instructions for importing a *.bcpkg file. They also have more on their web site.

A Beyond Compare “File Type” is sort of a filter that modifies the XML on-screen so it can be compared more meaningfully. It does not modify your original files – unless you make changes in BC and save it.

Once you import this File Type it will default to assuming any *.xml file is an SPF export file, and it will sort and tidy the XML to make it compare more meaningfully.

  • It sorts all exported objects by the ClassDef (XML element name)
  • It sorts all the interfaces inside each object by the interface name
  • It sorts all the attributes inside each interface
  • If there are multiple objects with the same ClassDef (e.g. multiple <Rel> or <SPXEngineeringDocRevision> elements in your export) then it will sub-sort those based on their UID.

So now you can more easily identify what data changes resulted from a method by:

  1. Right-mouse click an object, select Export Data, save to a “before” file
  2. Make some change to the object
  3. Again right-mouse click the object, select Export Data, save to an “after” file
  4. Open Beyond Compare to compare the two files
  5. In the File Type dropdown at the top of the Text Compare windows, select “SPF XML Sorted And Tidied” (do both sides)

Voila! All changes are highlighted in red. 🙂

Enjoy!

SPF Reporting – Creating SPF Schema Graph and View Definitions

I don’t use the Schema Editor for schema changes to SPF; I hand-code the updates in XMLSpy. This is pretty straightforward when modelling the more common objects like Classes, Interfaces and Properties. But Graph and View definitions are a little trickier.

I deconstructed some existing Graph and View definitions in order to create some new ones manually; this blog shows what I learned. In this explanation I gloss over the usual stuff like relationships between the objects; it’s the syntax of the definition strings that I go into detail on. This is based on SPF 4.3.3.

Continue reading