AnsweredAssumed Answered

Getting Coordinates for GetLinearizedStress

Question asked by Taus Moller on Dec 10, 2018
Latest reply on Jan 3, 2019 by Taus Moller

I am trying to use GetLinearizedStressValues with some consistency through the API. However i have difficulty with getting the right coordinates to use. In the sample they just insert static coordinates.  I have tried setting up some reference point/reference axis to get the coordinates. The issue is that the coordinates i get from this is in the global coordinate system which is apparently different from the coordinate system that GetLinearizedStress uses. Thus pulling the coordinates from the references and putting them into GetLinearizedStress yields an error. Is there some way to figure out the transformation from the global coordinate to the local coordinates of the stress plot? ICWPlot Interface Members doesn't list any method that seems to be related.

 

I have attached a sample part with a pressure vessle study. Another problem seems that the reference points i have placed cannot be used for the linearization. If i try doing it manually i am told that the points are invalid. Why are they invalid and how would i place valid reference points?

 

To get the linearies stress i use this macro:

 

public void DebugMethod()
        {

            ModelDoc2 doc = (ModelDoc2)SwApp.ActiveDoc;
            if (!(doc.SelectionManager is SelectionMgr selectionMgr))
                return;

            int numberOfSelections = selectionMgr.GetSelectedObjectCount2(-1);

            if (numberOfSelections <1)
            {
                return;
            }

            double[] samplepoints = new double[6];
            for (int i = 1; i <= numberOfSelections; ++i)
            {
                swSelectType_e selectedType = (swSelectType_e)selectionMgr.GetSelectedObjectType3(i, -1);
                switch (selectedType)
                {
                    case swSelectType_e.swSelDATUMPOINTS:
                        {
                            if (numberOfSelections != 2)
                                return;

                            Feature selectedfeature = (Feature)selectionMgr.GetSelectedObject6(i, -1);
                            RefPoint point = (RefPoint)selectedfeature.GetSpecificFeature2();
                            RefPointFeatureData featuredata = (RefPointFeatureData)selectedfeature.GetDefinition();
                            MathPoint mathpt = point.GetRefPoint();
                            double[] pointdata = (double[])mathpt.ArrayData;
                            samplepoints[(i-1) * 3] = pointdata[0];
                            samplepoints[(i-1) * 3+1] = pointdata[1];
                            samplepoints[(i-1) * 3+2] = pointdata[2];
                            break;
                        }
                    case swSelectType_e.swSelDATUMAXES:
                        {
                            if (numberOfSelections != 1)
                                return;

                            Feature selectedfeature = (Feature)selectionMgr.GetSelectedObject6(i, -1);


                            IRefAxis axis = (IRefAxis)selectedfeature.GetSpecificFeature2();
                            double[] axisparams = (double[])axis.GetRefAxisParams();
                            int j = 0;
                          
                            samplepoints = axisparams;
                           
                            break;
                        }
                    default:
                        return;
                }
            }

            CWStudyManager studyman = GetStudyManager();
            int studyindex = studyman.ActiveStudy;
            CWStudy study = studyman.GetStudy(studyindex);
            if (study != null)
            {
                CWResults res = study.Results;
                res.ActivatePlot("Stress1");
                object[] stress = (object[])res.GetLinearizedStressValues(0, samplepoints[0], samplepoints[1], samplepoints[2],
                                                                             samplepoints[3], samplepoints[4], samplepoints[5], 40, (int)swsStrengthUnit_e.swsStrengthUnitNewtonPerSquareMillimeter, out int error);

                Debug.Print("Linearized normal stresses in the X-direction:");
                Debug.Print("  Membrane:                     " + stress[0]);
                Debug.Print("  Bending (Point 1):            " + stress[1]);
                Debug.Print("  Membrane + Bending (Point 1): " + stress[2]);
                Debug.Print("  Bending (Point 2):            " + stress[3]);
                Debug.Print("  Membrane + Bending (Point 2): " + stress[4]);
                Debug.Print("  Peak (Point 1):               " + stress[5]);
                Debug.Print("  Peak (Point 2):               " + stress[6]);
            }



        }

Attachments

Outcomes