Hide or Show Bodies Sample

An Enterprise Knowledge Language (EKL) example for hiding or showing bodies.

This rule show the following behavior:

  • If a representation has a Geometrical Set or Body with a specific name:
    • It hides all the body and geometrical set except the one.
    • It is extracting this specific body/geometrical set to dedicated layer/color.
  • If the representation does not have a Body or a Geometrical Set with a specific name, there are no visible changes.

This rule can be further customized to support:

  • Show a body with name "LAYOUT" if it does have such body, and hide bodies with names "SKETCH", "ENVELOPE", "INSULATION", "MAINTENANCE", and so on.
  • If no body with name "LAYOUT" show body with name "SKETCH" and hide other bodies.
  • If also no body with name "SKETCH" , show body with name "EXACT", and so on.

Let child(Feature)
Let parent (Feature)
Let i (Integer)
Let tp (Type)
Let elements(List)
Let specificName(String)

set parent = NULL
Result = FALSE

// Here you should set the specific name, it could also be taken from a KWE attribute in the Drawing
specificName = "LAYOUT"


// first check we are working on some sub-elements of a PartFeature
if (Input.IsSupporting("BodyFeature") == TRUE or Input.IsSupporting("GeometricFeature")== TRUE or Input.IsSupporting("MMOrderedGeometricalSet") == TRUE or Input.IsSupporting("OpenBodyFeature") == TRUE) 
{

	// is it a set with the name
	if (Input.Name == specificName) 
	{
		// Change the layer and color as desired
		ActionList.Append("GraphicProperty(LineColor=215,150,40;Layer=111)")
		Result = TRUE
		
		//parent = GetPLMOwner(Input)
		//Trace(2,"Found GAPrep in #",parent.Name)
		
	}
	else
	{
		// retrieve the part feature to check what is inside
		//set tp = Input.PrimaryType
		//Trace(2,"primary type of the input #: #",Input.Name, tp.Name)
		if Input.IsASortOf("FunctionalBody") == TRUE
		{
			parent = NULL
		}
		else
		{
			parent = Input.Owner
		}
		//set tp = parent.PrimaryType
		//Trace(2,"primary type of the first parent: #",tp.Name)
		i = 0
		if (parent <> NULL)
		{
			for i while  parent.IsSupporting("PartFeature") <>TRUE and parent.IsSupporting("FunctionalBody") <>TRUE  and i< 10
			{
				set parent = parent.Owner
				if (parent <> NULL)
				{
					set tp = parent.PrimaryType
					//Trace(2,"primary type of the #eme parent: #",i, tp.Name)
				}
				else
				{
					break
				}
			}
			if i>=10
			{
				Message ("Problem on feature #",Input.Name) 
			}
		}
		// We have the part feature, let's scan it
		if (parent <> NULL )
		{
			if (parent.IsSupporting("PartFeature") or parent.IsSupporting("FunctionalBody"))
			{
				set elements = parent.Children 
				for child inside elements
				{
					// We know there is another set with the specific name
					if (child.Name == specificName) 
					{
						Result = TRUE
						ActionList.Append("NoShow()")
						
						//parent = GetPLMOwner(Input)
						//Trace(2,"do not show body: # as GAPrep is found in #",Input.Name, parent.Name)
						
						break
						
					}
				}
			}
		}
	}
}
//Message("Name : # , result: # ",Input.Name, Result)