make money

jav online; jav streaming; 1pondo; caribbeancom; heyzo - tokyo hot

Award Winning Design Blog

How To: Loop through all project piperuns using filters with Smartplant P&ID automation and VB6

By on January 14, 2011 in Programming, Smartplant, SPPID, Tutorial with 11 Comments

Programming using Smartplant P&ID’s Logical Automation Layer is actually very easy and intuative after you do it a few times.  This example of a what I start with a lot. What this little routine will do is loop through all the active (non stockpile) piperuns in your project and print their ItemTags in the immediate window. You could easily print them out to a txt file or excel spreadsheet too. For this to work you must have your desired project active.

Create a new .exe in VB6

Next, add your references (Project > References) – in this case we will need :

Intergraph Smartplant P&ID Automation and Intergraph SmartPlant Logical Model Automation

Create a new button on your form and double click it to open the code.  Paste the following in it:

Dim datasource As LMADataSource
Set datasource = New LMADataSource
Dim objFilter As LMAFilter
Dim criterion As LMACriterion

Set criterion = New LMACriterion
Set objFilter = New LMAFilter
'set the filters
criterion.SourceAttributeName = "ItemStatus"
criterion.ValueAttribute = "1"
criterion.Operator = "="
objFilter.ItemType = "Piperun"
objFilter.Criteria.Add criterion
Dim piperun As LMPipeRun
Dim piperuns As LMPipeRuns
Set piperuns = New LMPipeRuns
piperuns.Collect datasource, Filter:=objFilter
Debug.Print "Total Piperuns found:  " & piperuns.Count
'loop through each piperun
For Each piperun In piperuns
debug.print piperun.Attributes("ItemTag").Value
End If
Set datasource = Nothing
Set objFilter = Nothing
Set criterion = Nothing
Set piperun = Nothing
Set piperuns = Nothing

If you wanted to loop through all the piping components all you would have to do is change

Dim piperun As LMPipeRun
Dim piperuns As LMPipeRuns


Dim pipecomp As LMPipingComp
Dim pipecomps As LMPipingComps

and then change your filter type to

objFilter.ItemType = “PipingComp”

voilla, you are now looping through all the piping components.

Tags: , , , , ,

About the Author

About the Author: Hi! I am currently an Autodesk Solutions Engineer working to deliver real time solutions to our Enterprise customers. I have been involved with industrial design software for nearly 15 years and am a 3DS Max Professional who is passionate about design visualization. .


If you enjoyed this article, subscribe now to receive more just like it.

There Are 11 Brilliant Comments

Trackback URL | Comments RSS Feed

  1. Bhaskar says:


    I’m working as SmartPlant PID administrator. I’m new at automation part. When I connect the process Intergraph Smartplant P&ID Automation and Intergraph SmartPlant Logical Model Automation, it doesn’t works properly. The program does not identify even Llama.dll . I’ve already tried unregistering and registering Llama.dll, but in vain. I’ve tried it on smartplant pid 2009 as well as 4.3.

    Plz let me know how can I resolve the problem.
    Thanks in advance…

  2. dave says:

    did you register the two dll’s I listed in the post?

  3. Bhaskar says:

    I read in smartplant install guide that we need to upgrade the Llama.dll for version above 4.1. Is it so,I always need to build my own class and object for automation it is very time consuming. I believe Llama will reduce the work a lot.

  4. dave says:

    Bhaskar, sorry you’re having trouble. Can I suggest you post here:

    in greater detail and with some sample code?

  5. Bhaskar says:

    Thanx Dave. I did it by referncing several dll files. Thanx for your concern.

  6. pbp says:

    Which API do you use to access LMADataSource etc in VB?
    can you please provide steps.

  7. Sanchet says:

    hi, i am doing smartplant Administartor from last few days, can anyone please explain me about how to import excel file in smartplant.
    please help.
    If you hava any extra info. regarding administration please share with me. I want to be learn it more

Post a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.