Showing results for 
Search instead for 
Do you mean 
Reply

"The 12 Days of Rulestream"

15 REPLIES

Re: "The 12 Days of Rulestream"

Day 1:  “A Ref’rence to a KB”

A.K.A.: Adding a link to a Part Family to document its design
Top 2.jpg

The Documentation tab found on every Part Family is a useful place to store information pertaining to the design and details of the Part Family.  Unfortunately people rarely use it and when they do, if not diligent, the information provided may quickly become obsolete.

 

Something to consider:

Wouldn’t it be nice to link your Rulestream Part Family to the dynamic repository of all the information that went into the design of it? 

OneNote is a Microsoft product that comes with all recent versions of Office and allows you to save anything that comes across your computer.  From emails, to images, to meeting minutes, OneNote not only makes it easy to capture and find your data, but even allows sharing (I.e. collaboration) making it a great place to store all information relative to your project.  Linking this data directly to your model makes a complete package.

 

To link a OneNote Tab (or entire Notebook) to Rulestream:

1. Right-Click on the tab (or Notebook)

img1.jpg

2. Select the option to Copy Link

img2.jpg

3. Open Word

4. Paste your paste buffer into the document (it will appear with the name of the Tab/Notebook)

5. Add any additional documentation needed to explain the link and then save

img3.jpg

6. Open the Part Family that is to contain the reference link

7. Select the Documentation tab

8. Add the Word document using the [+] button

img4.jpg

 

 

To view the reference material from within the Part Family:

1. Go to the Part Family

2. Select the Documentation tab

3. Double-Click the Word document

img5.jpg

4. Select the link within the Word document

5. Interact dynamically with OneNote

img6.jpg

 

By linking to a dynamic repository of information you increase the likelihood that relevant and current documentation remains with the model you spent so much time developing.  There’s no need to write and maintain reference documents – all the information already used to define the Part Family is now accessible and remains updated with no extra effort.

Bottom Holiday.jpg

Re: "The 12 Days of Rulestream"

[ Edited ]

Day 2: “Two Alterna-doves”
A.K.A.: The case against Context Overrides

Top.jpg

Context overrides can be a powerful way of defining values or fomulas in a property depending on where the part family is used in the Product Control Model. However, they present two challenges:

1. Each context override is “hidden” in Architect which means that as a rule author, you must pull down the context and select it in order to see that context’s formula. If you do use context overrides, how often have you edited a formula only to find out later that you’ve edited the wrong context?

 

Context_Pulldown.png

 

2. Context overrides may pose a potential problem in the future when Rulestream implements rules configuration management. As a best practice, we discourage the use of context overrides to facilitate future upgrade paths.


Please note that context overrides may be unavoidable, especially for mating conditions in the Constraints of CAD specs. The following tips apply to properties only.

 

Two Alternatives
What are the alternatives? You can always find out what the parent is to define the value or formula of a property – from a single local context. For example, consider the part family called “Key_Button” in the following screenshot:

 

Context_Parent.png

 

The part family is used in two different places, each having a different parent. By using a select case statement, you can easily reference each parent’s part family name (system name) with “Me.Parent.PartFamily”: 

Dim p As String = Me.Parent.PartFamily

Select Case p
Case "Key_Monitor"
Result = 1.0
Case "Key_Panel"
Result = 2.0
End Select

What if you use the same “Key_Button” part family multiple times under the same parent, as in the screenshot below? This makes it more difficult to uniquely assign a value to the bottom two Key_Button part families using the method above. In this case, you can reference the system name of the subpart collection by using “Me.Owner.Name”:

 

Context_Owner.png

 

Dim o As String = Me.Owner.Name

Select Case o
Case "Inputs"
Result = 1.0
Case "Front"
Result = 2.0
Case "Right"
Result = 3.0
End Select

By using select case statements, one formula in a single context can represent the values for all contexts. It also prevents future upgrade problems when rules configuration management is implemented.

 

Bottom.jpg

 

Re: "The 12 Days of Rulestream"

[ Edited ]

Day 3: Three Turtle Doves

A.K.A. Part Family name uniqueness

Top.jpg

Don’t you just love a holiday story that begins with, “Back in the day…?” Well, here’s one such story for the third of our twelve days of Rulestream.

Use of Rulestream Applications

Back in the day of Rulestream 5.6, customers with large Rulestream projects began to run into a VB 6 size limitation when generating and compiling their rules, as Rulestream placed all generated rules into a single module. Rulestream at that time was based on VB 6 which had a hard limitation of 64K for local variables per module. As rulesets grew, this limitation eventually became a blocking issue for customers.


To work around this limitation, Rulestream introduced the concept of applications to contain part families while allowing rules in one application to refer to rules in another. Each application compiles into its own, individual VB module. By partitioning various part families across different applications, Rule Authors partitioned their part families across different VB modules so multiple 64K chunks could be used by a single Rulestream ruleset. Crisis avoided.


Once Rulestream moved the underlying platform to .NET (with the advent of Rulestream 6.0), this 64K limitation was no longer there, but over time, Rule Authors had found other advantages in use of Rulestream applications such as:


    - Better modularization and organization of rules


    - Ease of incremental deployment of rule updates for only part of a rules database


    - Finer-grained rule-authoring and rule-execution permissions


So Rulestream rule applications are very good and they are here to stay. However, there is one consideration that rule authors must heed.

Part Family Naming

As you know, part family names must be unique within their containing application, and this is enforced by Rulestream Architect. For example in application “A” you may have only one part family called “Turtle Dove”.


However, part family names are not required by Rulestream Architect to be unique across different applications. For example, you may also have a part family named “Turtle Dove” in applications “B” and “C”, for a total of “Three Turtle Doves”.


As explained above, often a single Rulestream product control model will contain part families from more than one application. At rule execution time, if you have several applications loaded which contain like-named part families, there may be ambiguity in just which part family the Rule Author meant in a subpart collection because there is no way today to specify a specific application in a subpart collection’s Optimal Part Family formula. Continuing the example above, if you have applications A, B, and C loaded in a running product control model, and a subpart includes “Turtle Dove”, you don’t know if application A, B, or C’s Turtle Dove will actually be loaded when a Turtle Dove is demanded.

Best Practice

For this reason, we recommend as a best practice that all part families be named uniquely across the entire rules database, not just within an application. This best practice, which is documented in more detail in Rulestream’s Enterprise Deployment Guide, recommends an application-specific, 2-3 character prefix be placed on all part family names within a Rulestream database. This will ensure each part family name is unique across the rules database and thus the specific part family that the rule author intended is actually instantiated when that is demanded.


We strongly suggest all customers follow this best practice. This, and other best practices for smoother deployments can be found in the Rulestream Enterprise Deployment Guide, available for download from the Rulesream release folders on GTAC.

Bottom.jpg

Re: "The 12 Days of Rulestream"

LOL...Funny Hannibal Lecter inference!

Re: "The 12 Days of Rulestream"

That is nice little trick. But why the need to insert directly into a Word document? Wouldn't a hyperlink work?

 

In OneNote you should have a Share icon on the top right. Once selected you can choose to Create a Hyperlink to the OneNote page.

OneNote Share Link.PNG

Re: "The 12 Days of Rulestream"

Hi Ryan,

 

I don't believe that the Documentation tab of a Part Family allows for the insertion of a hyper-link (something we need to consider adding).  To still use this tab I prefer to embed the link into a Word document not only to make the link available on this tab, but to fully document the link itself. 

 

I'm finding that the use of a tool such as OneNote, while requiring effort to make a habit, is a powerful tool for documentation and therefore lends itself nicely to to be linked with a tool like Rulestream.

 

By the way...  I don't seem to have the share icon appearing anywhere in my Notebook (OneNote 2013).  Any idea how to get that option to appear? 

Re: "The 12 Days of Rulestream"

Day 4: Four called events

A.K.A. What happens during a release including the four events that are called (or raised, for purists)

Top.jpg

Ever wonder about everything that happens during a Rulestream release? Well, here, for your holiday-season reading enjoyment, is the definitive sequence of precisely what happens during a release in Rulestream Engineer. This includes the "four called events", which may be used by the Rule Author to help do release-time automation.


1. The user clicks the release button,
OR the user clicks on the model->release menu,
OR g_RsEngineer.ReleaseModel(XMLRelease) is called.


2. The RsBeforeRelease event is raised. This is generally used by rule authors to perform checks and validations before the release is allowed to continue so that it could be prohibited by logic in this function. By setting e.Cancel to True, the release processing stops (the rest is cancelled).

 Public Sub g_RsEngineer_BeforeRelease(ByVal sender As Object, ByVal e As CancelEventArgs) Handles g_RsEngineer.RsBeforeRelease
MsgBox("Before Release Event.")
e.Cancel = False
End Sub


3. The user dialog box is displayed wherein the label, type, description, and other release options may be set by the user. If the User clicks Cancel, release processing stops (the rest is skipped).


4. g_RsEngineer.CurrentModel.ReleaseModel(label, type, description, run report, reports IDs) is called.
NOTE:  Rule authors wishing to skip the above dialog may call this function directly, however, the BeforeRelease event will not be raised. Do this with caution!


5. A RootPart.DemandParts() is run which fills out all parts within the PCM. The RootPart.ReleaseType and RootPart.ReleaseTypeName properties are set.


6. The component database outputs will happen, unless DelayComponentDBUpdate is set to true in the current profile.


7. The release line item records are created in the Project's database.


8. The RootPart.Release property is set to the new release number. The g_DocAcccess.ReleaseID is set to the new release number.


9. The RsBeforeContentRelease event is raised. This event is the first event in the release itself. It is raised after the user OKs the release dialog form. It is intended to be used to cause item number assignment to take place if running with a PLM system such as Teamcenter. This way the item IDs can be used in outputs (drawing title blocks, word documents) as well as drive the naming of release file names (for CAD, documents) which depend on the item ID. Generally, this is where Teamcenter items should be created/revised. If cancelled, all remaining release processing stops.

 Public Sub g_RsEngineer_BeforeContentRelease(ByVal sender As Object, ByVal e As CancelEventArgs) Handles g_RsEngineer.RsBeforeContentRelease
MsgBox("Before Content Release Event.")
TheRelease("Items") ' This does the TC item creation so IDs are available for the CAD model regeneration
e.Cancel = False
End Sub


10. All opened designer views (all integrations that have been opened by the user by clicking on a process step of that type, or because it is in the first process step) are notified to release. This is where CAD models and drawings are generated. At this time JT, DWG, Charting, and Word integrations do not generate outputs. A later 12-days article will cover how to do this.


11. The RsUserRelease event is raised. This event is raised after the integrations have generated all their content and before the demand all, saving of the release properties, and saving of the line item takes place. It is intended so that datasets that were just generated may be attached to the corresponding Teamcenter item revisions. If there is a failure, e.Cancel may be set to True to stop the rest of the release from happening.

 Public Sub g_RsEngineer_UserRelease(ByVal sender As Object, ByVal e As CancelEventArgs) Handles g_RsEngineer.RsUserRelease
MsgBox("User Release Event.")
' Right here is where you'll want to add calls to create outputs from JT, DWG, Charting, and Word integrations
TheRelease("Datasets") ' This does the TC dataset creation., where named references created above are added to the TC Item Rev.
e.Cancel = False
End Sub


12. The RootPart.CurrentProcessStep is set to "Release". The RootPart.InhibitWriteToReleaseTables property is checked. If it exists, the release tables are not written. This property may be used by the rule authors to stop lengthy releases when only documents and/or component database output is required. This should be used with caution. If the property is not defined, the release tables (model, part, subpart, property, spec, connection, etc.) are written to the Projects database. The RootPart.CurrentProcessStep is reset.


13. The release.bat is called with the following arguments (in order):
- The release folder
- The Project ID
- The Lineitem ID
- The Release ID
- The Release Type ID (from Release_Type table in ProjectDB)
- The UserID that did the Release
- g.DocAccess.CurrentDocumentFilePath
- The 1st UDF, starting with ProjectUDFs and then Line Item UDFs
- The 2nd UDF
- The 3rd UDF
...
- The "nth" UDF


The ReleaseBATWait profile setting controls whether this is a blocking call (in line call) or not. If set to True it is in line and release processing waits for the release.bat to finish. Otherwise, execution of the release immediately continues while release.bat continues.


14. The model XML file is written if XMLOut in the current profile is set to a valid folder path and file name.


15. The model tables in the Projects database are updated (the line item is saved).


16. The component database outputs will happen if DelayComponentDBUpdate is set to true in the current profile.


17. The RsAfterRelease event is raised. This is intended for use by the rule author to dispatch released files to other destinations, send email notifications and perform any other process once the release process proper is complete.

 Public Sub g_RsEngineer_AfterRelease(ByVal sender As Object, ByVal e As EventArgs) Handles g_RsEngineer.RsAfterRelease
MsgBox("After Release Event.")
End Sub


18. All model views are refreshed.


19. The delta report is run, if requested.


20. rootPart.ReleaseType is set to -1 and RootPart.ReleaseTypeName is set to nothing.


21. Release is complete.

Bottom.jpg

Re: "The 12 Days of Rulestream"

[ Edited ]

Day 5: Five Golden Queries

A.K.A.: How to find who changed what property between one date and another date

Top.jpg

This excellent tip comes from Bob Mattern of Babcock and Wilcox. Have you ever wanted a list of properties and part families that one user has changed within a certain date range? This is something that you cannot do (at the moment) from within Rulestream Architect, but it is possible to make these queries in SQL Server – the full version or even the express version.

In our example, we will use SQL Server 2012. To perform these queries, you will need rights to access the SQL Server, as well as the Rules database.

First, you will need to start the SQL Server Management Studio and select the SQL Server name that holds your Rulestream databases. Depending on the login authentication type, you may or may not need to enter your user name and password.

 

SQL_Login.png

 

As you may have multiple sets of Rulestream database in your SQL server, you will want to select the rules database against which you wish to run your query and then click the “New Query” button.

 

SQL_DBSelect.png

 

 This opens the Query window, where you can copy and paste the following script:

 

Select pf.PrettyName as "Part Family Name", ps.name as "Property Name",ps.Last_Update_Date as "property Last Update Date"
from dbo.Part_Family pf, dbo.property_spec ps
where ps.Last_Update_Date>='20160000'
and ps.Last_Update_Date<'20169999'
and ps.owner_Part_Family_ID = pf.Part_Family_ID
and ps.Last_Update_UserID = 'username'

 

where the last update dates for your date range are in the format ‘yyyymmdd’, and the username is the id of the Rulestream user.

When you click the “Execute” button on the toolbar, it will perform your query and return a list of results for the Part Family, Property and the date/time it was last changed at the bottom of the screen:

 

  SQL_Execute.png

  

Using this method, you can make queries on anything you want in the database. Here are some ideas (to round out the Five Golden Rings theme) for homework:

 

1. a list of properties and part families that one user has changed within a certain date range (see above)

2. a list of part families with a certain name

3. a list properties names and CAD feature names that are associated for a given part family

4. a list of property formulae containing a certain string

5. a list of applications, part families, and valid value formulae that use a database query

 

Bottom.jpg

Re: "The 12 Days of Rulestream"

[ Edited ]

Day 6: “More SQL Queries”

A.K.A.: Searching for a string in a Rules DB, Checking-In all Part Families and Checking-Out all Part Families

Top Holiday.jpg

In the course of moving, sharing and working with Rulestream applications that I did not create in order to test/debug, I’ve found it necessary on more than one occasion to do the following:

  • Find where a string exists within a Rulestream application (great when debugging or just familiarizing with an application)
  • Check-In all Part Families that may have been left in a Checked-Out state by previous rule architects
  • Check-Out all Part Families to me so that I can easily start working on updating the application

The following queries are executed within SQL Server Management Studio against the Rules Database containing the application in question. The first step is to login to the SQL Studio:


1. Provide the Server Name
2. Provide authentication information for connecting to the Server. In this example I’m using Windows Authentication  IM1.jpg3. Once connected to the server, expand the +Databases
4. Expand the +(Rules Database Desired) IM2.jpg

 

The following are the queries.

 

Search for a String within a Rulestream Application
This first one was already documented in one of our Knowledge Articles also found within this Community site. It has proven to be so useful for many that I’m re-describing it here.


5. Open a Query window (ex. New Query) and paste in the following:

SELECT
PFam.[Name] As PartFamily
,
PC
.[Name] As Property
,
PF
.
[Prop_Con_Id]
,PF.
[Formula_Type]
,PF.
[User_Edit]
,PF.
[Formula]
FROM [dbo].[Property_Formula] PF, [dbo].[Property_Constraint] PC, [dbo].
[Part_Family] PFam
WHERE formula LIKE
--'%MySearchText%'
'%Length%'
AND PF.[Prop_Con_Id] = PC.
[Prop_Con_Id]
AND PC.[Owner_Part_Family_ID] = PFam.
[Part_Family_ID]

6. Make sure that you’ll be running the query within the intended application
7. In this example, I would like to find all occurrences of the string “Length” within my application, so I place this string between ’%%’ as indicated:
IM3.jpg
8. Execute the query
9. All uses of the indicated string within the application are identified:
IM4.jpg

 

Check-In all Part Families
This little utility is setup so that you don’t need to run the query while within the context of the database. Instead, you enter the name of the database into the query.


5. Open a Query window (ex. New Query) and paste in the following being sure to enter the name of the Rules database on the second line between braces. In my example the Database is RS_Pump_Rules_8120:

UPDATE
[RS_Pump_RULES_8120].[dbo].
[Part_Family]
SET
Locked_By_UserID = '' WHERE Locked_By_UserID <> '*'
-- Place the user name within '' or use wildcard '*' for all

6. In this example I will check-in all Part Families rather than those belonging to a specific user ID by using a wildcard ‘*’. If I wanted to Check-In all Part Families currently checked out by RSmith I’d enter ‘RSmith’:

IM5.jpg
7. Execute the query
8. All Part Families that were Checked-Out as specified are now Checked-In:
IM6.jpg

 

Check-Out all Part Families
As with the previous example, this utility is setup so that you don’t need to run the query while within the context of the database. Instead, you enter the name of the database into the query.


5. Open a Query window (ex. New Query) and paste in the following being sure to enter the name of the Rules database on the second line between braces. In my example the Database is RS_Pump_Rules_8120:

UPDATE
[RS_Pump_RULES_8120].[dbo].
[Part_Family]
SET
Locked_By_UserID = 'tboucher'
-- Place the user name within ''

6. In this example I will check-out all Part Families to me using my ID ‘tboucher’:

IM7.jpg
7. Execute the query
8. All Part Families have now been Checked-Out to me:  IM8.jpg

 

With a data structure built upon tables within a SQL Server database, there are many tools, tips and tricks for finding information within the tables. If you have access to your data tables, utilities such as the ones above may be run with no risk to your application. But please be aware, it is also possible to make inadvertent changes to your data that may potentially corrupt your entire application. Run queries with caution and, when in doubt, backup the database first.


Queries that simply return data, such as the Search one above, are always safe to run. Those that alter the data, such as the Check-In/Out ones, need to be run with caution.

Bottom.jpg