I have a group/component/selected set of nodes, and I want to find the average position. How can I do this?
This may be desirable in a number of situations; for example, to find the approximate centroid of a surface that was a named selection in Simulation. You will have to *VGET an array for the coordinates of all nodes (*VGET,allX,NODE,1,LOC,X), *VGET an array for the selected state of all nodes (*VGET,maskX,NODE,1,NSEL), mask the unselected nodes from the following operation (*VMASK,maskX), then calculate the average position of the selected nodes (*VSCFUN,avgX,MEAN,allX). Repeat this for Y and Z, then you will have the coordinates of the average position of the nodes (avgX,avgY,avgZ). *VGET,allX,NODE,1,LOC,X *VGET,maskX,NODE,1,NSEL *VMASK,maskX *VSCFUN,avgX,MEAN,allX *VGET,allY,NODE,1,LOC,Y *VGET,maskY,NODE,1,NSEL *VMASK,maskY *VSCFUN,avgY,MEAN,allY *VGET,allZ,NODE,1,LOC,Z *VGET,maskZ,NODE,1,NSEL *VMASK,maskZ *VSCFUN,avgZ,MEAN,allZ |
||
|