Kkula
Browse Questions » Plant Engineering Software COMOS: How Towards Retrieve pipe object Originating From associated pipe flag

About User

Questions Asked: 3.6K

Answers Given: 0

0
  • Open
  • New

Plant Engineering Software COMOS: How Towards Retrieve pipe object Originating From associated pipe flag

Hi 
I would like to display all pipelines, pipe sections and pipe segments with associated flags in one query.
For pipe flags no object is created in the unit tree. I can get to the pipe flags via global castings, but I don't know how to get to the associated pipe sections.
currently I have the following script. does anyone know how to proceed here?
Set GC = CreateObject("ComosROUtilities.GlobalCastings")
strFlagCDev = "@30|M00|A50|A10|A80|A10|A40"
Set objDoc = a
objDoc.Report.OpenReadOnly true
Set colRItems = objDoc.Report.ReportDocument
For i = 0 To colRItems.Itemcount-1
   Set rItem = colRItems.item(i)
   Set roDevice = GC.GC_GetIRODevice(rItem)
   If Not roDevice Is Nothing Then
      If strFlagCDev = roDevice.CDeviceFullname Then
         Output "Flag found"
      End If
   End If
Next
objDoc.Report.close

0 Likes 0 Favourites 0 Followers 0 Comments
Answers(1)

Displaying Pipelines, Sections & Flags with Associations

You're on the right track using Global Castings to access pipe flags. However, to reach the associated pipe sections, you need to traverse the relationships defined within COMOS.

Here's a refined approach, building upon your script:

  1. Access Pipe Flags: Your current method using GlobalCastings to find flags by CDeviceFullname is valid.
  2. Navigate to Pipe Section: Once you've identified a flag (roDevice), utilize its relationships to find the parent pipe section. Flags are typically related to sections via a "Contains" or similar relationship. Use roDevice.Parent or explore roDevice.Relationships to find the section.
  3. Access Pipeline: From the pipe section, navigate to its parent pipeline using the same approach (pipeSection.Parent or pipeSection.Relationships).
  4. Output Information: Output the relevant properties of the pipeline, pipe section, and flag.

Example Snippet (Illustrative):

Set GC = CreateObject("ComosROUtilities.GlobalCastings")
strFlagCDev = "@30|M00|A50|A10|A80|A10|A40"
Set objDoc = a
objDoc.Report.OpenReadOnly True
Set colRItems = objDoc.Report.ReportDocument

For i = 0 To colRItems.Itemcount - 1
  Set rItem = colRItems.item(i)
  Set roDevice = GC.GC_GetIRODevice(rItem)

  If Not roDevice Is Nothing Then
    If strFlagCDev = roDevice.CDeviceFullname Then
      Output "Flag found: " & roDevice.CDeviceFullname

      'Navigate to Pipe Section (Adapt relationship name as needed)
      If Not roDevice.Parent Is Nothing Then
        Set roPipeSection = roDevice.Parent
        Output "  Pipe Section: " & roPipeSection.CDeviceFullname

        'Navigate to Pipeline (Adapt relationship name as needed)
        If Not roPipeSection.Parent Is Nothing Then
          Set roPipeline = roPipeSection.Parent
          Output "   Pipeline: " & roPipeline.CDeviceFullname
        End If
      End If
    End If
  End If
Next

objDoc.Report.close

Important: Replace placeholder relationship names (e.g., "Contains") with the actual relationship names used in your COMOS project. Use the COMOS object model browser to explore relationships. Consider using more specific queries targeting the flag's object type directly for performance.

For detailed information on relationships and the COMOS object model, refer to the SiePortal: SiePortal.

0
Add a comment