Using a Rule to determine the orientation of a groove in a turned part

40 views
Skip to first unread message

srikanth vadapalli

unread,
Oct 17, 2013, 5:12:55 AM10/17/13
to catiat...@googlegroups.com
INTRODUCTION

This article presents a method to use a Knowledge Advisor Rule to determine the orientation of a groove feature on a turned, or rotational symmetric part. 


PROBLEM 

Input Geometry

We are given a sections representing the shape of a turned part
Also indicated is a line representing the turning axis;  a point far away on the turning axis on the "Top" end if the part; and a point clearly inside the groove to identify.

Output Parameter
A String Parameter named GROOVE_ORIENTATION will have it's value set by the rule

Assumptions:
  1. Section, axis, position point and top reference point are all on the same plane
  2. Position point is not on the axis
  3. Position point is "clearly inside" the groove to be extracted
  4. Top reference point is far from the section - A plane perpendicular to the axis through the top reference point must not intersect the section.

Solution Architecture

A Rule will be used to compute the result from four possible answers: "TOP", "BOTTOM", "ID",  "OD", and "ERROR".

Here is the tree structure

 

Note that GROOVE_ORIENTATION and GROOVE_EXTRACTION_OFFSET are aggregated to the NC_GROOVE datum curve.  Localizing the parameters like this makes it clear which parameters belong to which feature when there are may features instantiated in a part. 


To determine the orientation of the groove and write this value to the GROOVE_ORIENTATION parameter the Rule constructs and operates on temporary geometry. Tempoary geometry used in a Rule is never drawn on the screen unless it is assigned to a Datum. The overhead is low for doing this kind of computation in rules compared to VB scripting solutions. Performance is excellent.  
 
This is how the algorithm to determine the orientation of the groove works: 

1.  A very long (10m) line is made at the position point parallel to the axis direction

l1 = line(pos,direction(axis),0m,10m,true)


2. In a loop the line is rotated 90 degrees at a time about the position point.
3. At each position the distance between the line to the section is measured.
4. If the distance is zero, the line intersects with the section so that line cannot indicate the direction out of the groove feature.


for i while i < 4
{
delta = i * 90deg
 l2 = lineangle(l1,plx,pos,true,0m,10m,delta,true)
/*  Message("i = # d = #",i,distance(l2,section)) */
if distance(l2,section) > 0m 
{
set l3 = l2
cnt = cnt + 1
/*  Message("#",cnt)   */
}
i = i + 1
}

Line and Section intersect so the distance is zero.

5. If the distance is larger then zero, the line indicates a direction out of the feature.


Line and Section do not intersect so the distance is non-zero.

6. The number of times the distance is greater then zero is counted. There should be only one result.

if cnt == 1
{

7. if the line is parallel to the axis, the relative position of the point and the line indicates a TOP or BOTTOM orientation.

/* measure angle to axis */
delta = angle(l3,axis)
/*   Message("#",delta)   */
/* if parallel then it is top or bottom */
if delta == 0deg or delta == 180deg 
{
/* if  l3 is closer to topRef then pos, then orient is TOP
otherwise orientation is BOTTOM */
if distance(l3,topRef) < distance(pos,topRef) 
orient = "TOP"
}
else
{
orient = "BOTTOM"
}
}


8. If the line is perpendicular to the axis, the distance from the line to the axis indicates ID or OD.

/* if perpendicular then ID or OD */
else
{
/* check distance to axis . If zero answer is ID */
if distance(l3,axis)  == 0m
{
orient = "ID"
}
else
{
orient = "OD"
}
}


9. If zero or more then one intersection was found, then "ERROR" is returned:

else
{
orient = "ERROR"
}


Here is the full code of the rule 

/* define variables */
let section (Curve)
let pos (Point)
let axis (Line)
let topRef  (Point)
let orient (String)

let plx (Plane)
let lx (Line)
let lz (Line)
let l1 (Line)
let l2 (Line)
let l3 (Line)
let i (Integer)
let cnt (Integer)
let delta (Angle)

/* get inputs  */
section = INPUTS\PART_SECTION 
pos = INPUTS\Point.12 
axis = INPUTS\AXIS 
topRef = INPUTS\POS_X_REF_PT 

plx = plane(section)


/* make a long line starting at pos parallel to the axis */

l1 = line(pos,direction(axis),0m,10m,true)

/* measure from the line to the section. Rotate by 90deg until a non-zero distance is found. 
This will be the open end of the groove */
i = 0
cnt = 0
for i while i < 4
{
delta = i * 90deg
 l2 = lineangle(l1,plx,pos,true,0m,10m,delta,true)
/*  Message("i = # d = #",i,distance(l2,section)) */
if distance(l2,section) > 0m 
{
set l3 = l2
cnt = cnt + 1
/*  Message("#",cnt)   */
}
i = i + 1
}
if cnt == 1
{
/* measure angle to axis */
delta = angle(l3,axis)
/*   Message("#",delta)   */
/* if parallel then it is top or bottom */
if delta == 0deg or delta == 180deg 
{
/* if  l3 is closer to topRef then pos, then orient is TOP
otherwise orientation is BOTTOM */
if distance(l3,topRef) < distance(pos,topRef) 
orient = "TOP"
}
else
{
orient = "BOTTOM"
}
}
/* if perpendicular then ID or OD */
else
{
/* check distance to axis . If zero answer is ID */
if distance(l3,axis)  == 0m
{
orient = "ID"
}
else
{
orient = "OD"
}
}
}
else
{
orient = "ERROR"
}

/* assign output */
OUTPUTS\NC_GROOVE\GROOVE_ORIENTATION  = orient
/* END OF CODE */

Here is the tree after the rule is implemented. The icon GROOVE_ORIENTATION parameter indicates that it is a "driven" parameter.
Reply all
Reply to author
Forward
0 new messages