Hello Everyone,
I have cube. When i select i face i wanted to calculate the center of it. I implemented the functionality to get GetSectionProperties2 of the selected object. This gave me the X,Y,Z of the center but in Global coordinates (Model coordinates). I wanted to now transfer the coordinates to the face coordinates of the cube (i wanted to use center of face to do some calculations). I tried implementing a math transform but it is not giving me the right coordinates. I have posten the code for mathtransform below. I tried checking online also but it has examples for sketch to model coordinates and not the other way.
Any help will be appreciated
Dim vPtArr As Variant
Dim Sketch As SldWorks.Sketch
Dim ModelToSketchTransform As SldWorks.MathTransform
ReDim vPtArr(3)
vPtArr(0) = v1(2) ' v1 is the variant where the 3D sketch point is stored
vPtArr(1) = v1(3)
vPtArr(2) = v1(4)
Debug.Print vPtArr(0)
Debug.Print vPtArr(1)
Debug.Print vPtArr(2)
swSkMgr.InsertSketch True
Set swMathUtil = swApp.GetMathUtility
Set swMathPoint = swMathUtil.CreatePoint(vPtArr)
Set Sketch = swModelDoc.GetActiveSketch2
Set ModelToSketchTransform = Sketch.ModelToSketchTransform
Set swMathPoint = swMathPoint.MultiplyTransform(ModelToSketchTransform)
Dim vModelSelPt As Variant
vModelSelPt = swMathPoint.ArrayData
Debug.Print vModelSelPt(0)
Debug.Print vModelSelPt(1)
Debug.Print vModelSelPt(2)
Regards,
Prashant Mohan
SolidworksApi macros