> Insert Spline in Drawing Example (C++ COM)
Welcome
Getting Started
SolidWorks API Help
FeatureWorks API Help
SolidWorks Document Manager API Help
eDrawings API Help
SolidWorks Routing API Help
SolidWorks Simulation API Help
SolidWorks Utilities API Help
SolidWorks Workgroup PDM API Help
Hide Table of Contents Show 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;

}

 



Related SolidWorks Forum Content

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:  
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

The search functionality within the web help is in a beta test phase and you may experience periodic delays or interruptions in its performance. These are the normal and ordinary features of a beta test and shall not under any circumstances give rise to any liability on the part of DS SolidWorks or its licensors. The topics within the Web-based help are not beta topics; they document 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.