3 Replies Latest reply on Aug 8, 2013 10:00 PM by Wang Shuai

    How to use CreateTrimmedSheet in C++?

    Wang Shuai

      Hi

      I am a beginner with SolidWorks and its API. I am developing using usually “ordinary simple C++” ,too.

      I try to use 'CreateTrimmedSheet' following the example "Create Temporary Extruded Body Example (VBA)"

      But when I use  CreateTrimmedSheet,  I don't know how to convert parameter 1 form 'ICurve*' to VARIANT'. Please help me. Thank you so much.

      The VBA is below.

      ptArr(0) = 0#

      ptArr(1) = 0#

      ptArr(2) = 0#

      dirArr(0) = 0#

      dirArr(1) = 0#

      dirArr(2) = 1#

      startArr(0) = 1#

      startArr(1) = 0#

      startArr(2) = 0#

      Set planeSurf = swModeler.CreatePlanarSurface2((ptArr), (dirArr), (startArr))

       

      ptArr(0) = -halfLength

      ptArr(1) = halfWidth

      ptArr(2) = 0#

      dirArr(0) = 1#

      dirArr(1) = 0#

      dirArr(2) = 0#

      Set trimCurves(0) = swModeler.CreateLine((ptArr), (dirArr))

      Set trimCurves(0) = trimCurves(0).CreateTrimmedCurve2(-halfLength, halfWidth, 0#, halfLength, halfWidth, 0#)

       

      ptArr(0) = halfLength

      ptArr(1) = 0#

      ptArr(2) = 0#

      startArr(0) = halfLength

      startArr(1) = halfWidth

      startArr(2) = 0#

      endArr(0) = halfLength

      endArr(1) = -halfWidth

      endArr(2) = 0#

      dirArr(0) = 0#

      dirArr(1) = 0#

      dirArr(2) = -1#

      Set trimCurves(1) = swModeler.CreateArc((ptArr), (dirArr), halfWidth, (startArr), (endArr))

      Set trimCurves(1) = trimCurves(1).CreateTrimmedCurve2(halfLength, halfWidth, 0#, halfLength, -halfWidth, 0#)

       

      ptArr(0) = halfLength

      ptArr(1) = -halfWidth

      ptArr(2) = 0#

      dirArr(0) = -1#

      dirArr(1) = 0#

      dirArr(2) = 0#

      Set trimCurves(2) = swModeler.CreateLine((ptArr), (dirArr))

      Set trimCurves(2) = trimCurves(2).CreateTrimmedCurve2(halfLength, -halfWidth, 0#, -halfLength, -halfWidth, 0#)

       

      ptArr(0) = -halfLength

      ptArr(1) = 0#

      ptArr(2) = 0#

      startArr(0) = -halfLength

      startArr(1) = -halfWidth

      startArr(2) = 0#

      endArr(0) = -halfLength

      endArr(1) = halfWidth

      endArr(2) = 0#

      dirArr(0) = 0#

      dirArr(1) = 0#

      dirArr(2) = -1#

      Set trimCurves(3) = swModeler.CreateArc((ptArr), (dirArr), halfWidth, (startArr), (endArr))

      Set trimCurves(3) = trimCurves(3).CreateTrimmedCurve2(-halfLength, -halfWidth, 0#, -halfLength, halfWidth, 0#)

       

      Dim profileBody As SldWorks.Body2

      Dim extrudedBody As SldWorks.Body2

      Dim dirVector As SldWorks.MathVector

       

      Set profileBody = planeSurf.CreateTrimmedSheet((trimCurves))