Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Method to add the InsertConstrain... Where is the bug?

0 REPLIES 0
Reply
Message 1 of 1
chaiy
162 Views, 0 Replies

Method to add the InsertConstrain... Where is the bug?

I tried to use some function with VC++ to select 2 Circular Edges and make insert Contrain them together.I have made a code but it has some mistake.It is not work.If some one kwon,Please help me.

best regrads,

  • *****************************************
  • Document* aDoc;

    // Chaeck Assembly's Document

    HRESULT Result = NOERROR;
    Result = m_Application->get_ActiveDocument(&aDoc);

    if (FAILED(Result) || !aDoc)
    {
    BSTR stTempFile;
    CComVariant MyDocSubType(L"SubType");
    m_Application->GetTemplateFile(kAssemblyDocumentObject, kDefaultSystemOfMeasure,
    kDefault_DraftingStandard, MyDocSubType, &stTempFile);
    aDoc->Release();
    aDoc = NULL;
    Documents* aDocs = m_Application->GetDocuments();
    aDocs->Add(kAssemblyDocumentObject, stTempFile, TRUE, &aDoc);//erzeugt Absturz
    CWnd::GetActiveWindow()->MessageBox("punkt drei", "Wegpunkt", MB_OK|MB_ICONERROR);
    }

    // Result = m_Application->get_ActiveEditObject(&aActObj);
    // if (FAILED(Result) || !aActObj)
    // return;

    CComQIPtr<AssemblyDocument> aAsmDoc(aDoc);

    CComQIPtr<AssemblyComponentDefinition> aAsmComDef;
    Result = aAsmDoc->get_ComponentDefinition(&aAsmComDef);

    InteractionEventsObject* oInteractEvents;
    SelectEventsObject* oSelectEvents;

    bool checkSelected = false;

    Result = m_Application->CommandManager->CreateInteractionEvents(&oInteractEvents);

    Result = oInteractEvents->put_SelectionActive(true);

    oSelectEvents = oInteractEvents->GetSelectEvents();

    Result = oSelectEvents->AddSelectionFilter(filter);

    Result = oInteractEvents->Start();

    int edge_Num = 0;
    int SelectCount = 0;
    CComQIPtr<Edge> aEdge[2];

    CComPtr<ObjectsEnumerator> oSelectedEnts ;
    AfxMessageBox("in Pick 2");

    Result = oSelectEvents->get_SelectedEntities(&oSelectedEnts);

    while(!checkSelected)
    {

    // SelectCount = oSelectedEnts->GetCount();

    if (oSelectedEnts->GetCount() > 2)
    {
    checkSelected = true;
    }

    edge_Num++;
    }

    aEdge[0] = oSelectedEnts->GetItem(1);
    aEdge[1] = oSelectedEnts->GetItem(2);

    CComPtr<InsertConstraint> aInsert;
    CComVariant Distance=0.0,
    BiasPointOne = 0.0,
    BiasPointTwo = 0.0;

    aInsert=aAsmComDef->Constraints->MethodAddInsertConstraint(aEdge[0],aEdge[1],true,Distance
    ,BiasPointOne,BiasPointTwo);

    /********************************************

    0 REPLIES 0

    Can't find what you're looking for? Ask the community or share your knowledge.

    Post to forums