Cancel
Showing results for 
Search instead for 
Did you mean: 

Body center point

Siemens Creator Siemens Creator
Siemens Creator

Hi,

 

I'm coding on Nx-Open Java and I want to ask please how can I get the body center point.

 

Thanks.

4 REPLIES

Re: Body center point

Esteemed Contributor
Esteemed Contributor

The mass center point or just the space center?

For the center in space use AskBoundingBoxExact to get the maximum space used and use the size of the returned box to calculate the center of it.

For the center of mass record a journal of getting this interactively.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community

Re: Body center point

Esteemed Contributor
Esteemed Contributor
Dim oOrigin As Point3d = New Point3d()
Dim oMatrix As Matrix3x3 = New Matrix3x3()
Dim dMinCorner(2), dDirections(2,2), dDistances(2), As Double

With oMatrix
	.Xx = 1.0
	.Yy = 1.0
	.Zz = 1.0
End With

With oOrigin
	.X = 0.0
	.Y = 0.0
	.Z = 0.0
End With

Dim oCSYS As CartesianCoordinateSystem = _
	theSession.Parts.Work.CoordinateSystems.CreateCoordinateSystem(oOrigin, oMatrix, True)

theUFSession.Modl.AskBoundingBoxExact(oBody.Tag, oCSYS.Tag, dMinCorner, dDirections, dDistances)

CenterX = dMinCorner(0) + dDistances(0) / 2.0
CenterY = dMinCorner(1) + dDistances(1) / 2.0
CenterZ = dMinCorner(2) + dDistances(2) / 2.0

Example code is VB.NET

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community

Re: Body center point

Siemens Creator Siemens Creator
Siemens Creator

Thanks.

I just understand that I didn't get the things right.

I thought that the body I had was the whole work-part, but it didn't.

 

Is there a way to merge bodies and treat them at one body? Or to get the whole work-part center point?

 

Thanks.

Re: Body center point

Esteemed Contributor
Esteemed Contributor

How about getting the center of all bodies in the part and calculating the overall center based on them?

  1. Get the lowest and highest coordinate for each axis
  2. Add both values for each axis together and divide by two

To easier do this create three List(Of Double) and add the point coordinates as you check the bodies.

Sort the three lists and you will have the first and the last item of each list to get the average from.

This should give you the center of all bodies.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community