Hide Table of Contents

Insert Spline in Drawing Example (C++ COM)

This example shows how to insert a spline in a drawing.

 

STDMETHODIMP CDgtlPen::demo3()

{

    HRESULT                                 hr = S_OK;

    CComPtr <IModelDoc2>                    pModel;

    CComQIPtr <IDrawingDoc>                 pDraw;

    CComPtr <IView>                         pView;

    CComPtr <IView>                         pFocusLockedView;

    CComPtr <ISheet>                        pSheet;

    int                                     pPropArray[4];

    double                                  pKnotsArray[11];

    double                                  pCntrlPntCoordArray[21];

    VARIANT_BOOL                            updateEditRebuild = TRUE;

    long                                    retval = NULL;

    VARIANT_BOOL                            focusLocked = NULL;

    ZeroMemory(pPropArray, 4 * sizeof(int));

    ZeroMemory(pKnotsArray, 11 * sizeof(double));

    ZeroMemory(pCntrlPntCoordArray, 21 * sizeof(double));

    pPropArray[0] = 3;      //Dimension

    pPropArray[1] = 4;      //Order

    pPropArray[2] = 7;      //Number of control Points

    pPropArray[3] = 0;      //Periodicity

    pKnotsArray[0] = 0;

    pKnotsArray[1] = 0;

    pKnotsArray[2] = 0;

    pKnotsArray[3] = 0;

    pKnotsArray[4] = 0.3;

    pKnotsArray[5] = 0.3;

    pKnotsArray[6] = 0.6;

    pKnotsArray[7] = 1;

    pKnotsArray[8] = 1;

    pKnotsArray[9] = 1;

    pKnotsArray[10] = 1;

    pCntrlPntCoordArray[0] = -0.1;      pCntrlPntCoordArray[1] = -0.009;    pCntrlPntCoordArray[2] = 0;

    pCntrlPntCoordArray[3] = -0.11;     pCntrlPntCoordArray[4] = 0.013;     pCntrlPntCoordArray[5] = 0;

    pCntrlPntCoordArray[6] = -0.14;     pCntrlPntCoordArray[7] = 0.035;     pCntrlPntCoordArray[8] = 0;

    pCntrlPntCoordArray[9] = 0.015;     pCntrlPntCoordArray[10] = 0.019;    pCntrlPntCoordArray[11] = 0;

    pCntrlPntCoordArray[12] = -0.059;   pCntrlPntCoordArray[13] = -0.024;   pCntrlPntCoordArray[14] = 0;

    pCntrlPntCoordArray[15] = 0.012;    pCntrlPntCoordArray[16] = -0.018;   pCntrlPntCoordArray[17] = 0;

    pCntrlPntCoordArray[18] = 0.054;    pCntrlPntCoordArray[19] = -0.013;   pCntrlPntCoordArray[20] = 0;

    hr = m_iSldWorks->get_IActiveDoc2(&pModel);

    _ASSERT(pModel);

    pDraw = pModel;

    _ASSERT(pDraw);

    hr = pDraw->IGetFirstView(&pView);

    _ASSERT(pView);

    while(pView != NULL)

    {   

        CComPtr <IView>                     pNextView;

        hr = pView->get_FocusLocked(&focusLocked);

        

        if (focusLocked)

        {

            pFocusLockedView = pView;

            _ASSERT(pView);

            pView = NULL;

        }

        else

        {

            hr = pView->IGetNextView(&pNextView);

            pView = NULL;

            pView = pNextView;

        }

    }

    hr = pDraw->IGetCurrentSheet(&pSheet);

    _ASSERT(pSheet);

    hr = pSheet->get_FocusLocked(&focusLocked);

    hr = pSheet->put_FocusLocked (TRUE);

    

    hr = pModel->InsertSketch2(updateEditRebuild);

    hr = pModel->ISketchSplineByEqnParams(pPropArray, pKnotsArray, pCntrlPntCoordArray, &retval);

    _ASSERT(retval);

    hr = pSheet->put_FocusLocked(focusLocked);

    if(pFocusLockedView != NULL)

        {

        hr = pFocusLockedView->put_FocusLocked(TRUE);

        }

    hr = pModel->GraphicsRedraw2();

    return S_OK;

}

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Insert Spline in Drawing Example (C++ COM)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2012 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.