Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX Journal - Reporting the Delta (Component) Distances between 2 Objects 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
I was using AskMinimumDist to find the minimum distance between 2 objects in my NX Journal. I now realize that it would be much more useful to get the component (Delta X,Delta Y,Delta Z) distance measurements instead of the true 3D distance.

But, of course, I can't figure out how to do that.

Any suggestions?

Thanks,
Jeff
 
Replies continue below

Recommended for you

AskMinimumDist(
Tag object1,
Tag object2,
int guess1_given,
double[] guess1,
int guess2_given,
double[] guess2,
out double min_dist,
double[] pt_on_obj1,
double[] pt_on_obj2

)

The last two arguments return the co-ordinates of point on each object. You can easily calculate the delta values.

Suresh
 
Right, I just realized that after I posted the question.

Unfortunately, I also just realized that I was trying to use the delta values because I thought I wanted the distances in the direction of each of the axes for my problem. Once I did that, I then realized that what I actually wanted was the distance between the 2 objects in a direction perpendicular or normal to one of the objects - and that direction isn't always along an axis.

Jeff
 
Sorry, I really should spend a little more time figuring things out before I post. Here's what I figured out:

Code:
Function MeasObjToObj(Obj1, Obj2)
Dim measureDistanceBuilder1 As NXOpen.MeasureDistanceBuilder = Nothing
BodyFaces() as NXOpen.Face
		
BodyFaces=obj1.getfaces
		
Dim face1 As NXOpen.Face = BodyFaces(0)
Dim direction1 As NXOpen.Direction
Dim ProjDist as double
Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)

direction1 = workPart.Directions.CreateDirection(face1, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.AfterModeling)
		
measureDistanceBuilder1 = workPart.MeasureManager.CreateMeasureDistanceBuilder(nullNXOpen_NXObject)
measureDistanceBuilder1.Mtype = NXOpen.MeasureDistanceBuilder.MeasureType.Minimum
measureDistanceBuilder1.ProjectionVector = direction1
measureDistanceBuilder1.Object1.Value = obj1
measureDistanceBuilder1.Object2.Value = obj2
Dim measureDistance1 As MeasureDistance
measureDistance1 = workPart.MeasureManager.NewDistance(unit1, obj1, obj2, direction1)
ProjDist = measureDistance1.value
lw.writeline(ProjDist)
measureDistanceBuilder1.Destroy()
Return ProjDist
End Function

Hope it helps someone else.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor