Insert part to assembly in 3DEXPERIENCE macro

1.1k Views Asked by At

Does anybody some experiences with inserting part to assembly in Catia 3DEXPERIENCE? No matter what language used. I'm just looking for some lead.

I have no problem to find or open the part from the database but I'd need to know how to insert this object into already opened product.

I'd be glad for any answer or tip.

My point is that I'd like to insert into assembly item found in the database for example from method like this:

    public DatabaseSearch SearchItemInDB(string searchString)
    {
        SearchService oSearchService = (SearchService)CATIA.GetSessionService("Search");

        DatabaseSearch oDatabaseSearch = oSearchService.DatabaseSearch;
        oDatabaseSearch.set_BaseType("VPMReference");
        oDatabaseSearch.AddEasyCriteria("V_Name", searchString);

        oSearchService.Search();

        return oDatabaseSearch;
    }

Thanks in advance.

Jiri

2

There are 2 best solutions below

0
On BEST ANSWER

I really appreciate effort of people who contributed to this discussion. I came to the conclusion that it is not possible to insert item to the assembly directly from the database search and i did it by simple copying item from another editor.

        private Editor OpenProductAndGetEditor(DatabaseSearch oDBSearch)
    {
        PLMEntities cPLMEntititiesFound = oDBSearch.Results;

        if (cPLMEntititiesFound.Count > 0 && cPLMEntititiesFound.Count < 2)
        {
            oPLMEntityFound = cPLMEntititiesFound.Item(1);
            
            PLMOpenService oPLMOpenService = (PLMOpenService)CATIA.GetSessionService("PLMOpenService");


            oPLMOpenService.PLMOpen(oPLMEntityFound, out oFoundEditor);

            model.InfoAboutSearching = "Object found: " + oPLMEntityFound.get_Name();
            BItemFound = true;

        }
        return oFoundEditor;
    }

    private void CopyOpenedPart(Editor oEditor)
    {
        PLMProductService oProductService = (PLMProductService)oEditor.GetService("PLMProductService");

        VPMRootOccurrence oCompRootOccur = oProductService.RootOccurrence;

        Selection tempSel = oEditor.Selection;

        tempSel.Clear();
        tempSel.Add(oCompRootOccur);
        tempSel.Copy();
        tempSel.Clear();

        Window oCurrentWindow = CATIA.Windows.Item(2);

        oSel.Add(oVPMOccurSwitchboard);
        oSel.Paste();
        oSel.Clear();

        oCurrentWindow.Close();

    }

if anyone knows the solution to this topic, I will be happy to contact me.

Thanks

1
On

Try something like this in VB:

Public Function CopyPaste(ByRef MyInObj As AnyObject, ByRef MyOutObj As AnyObject)

    Dim MaSel As INFITF.Selection = CATIA.ActiveEditor.Selection

    '********************
    '* Copy file *
    '********************
     MaSel = CATIA.ActiveEditor.Selection
     MaSel.Clear()
     MaSel.Add(MyInObj)
     MaSel.Copy() 


    '**************
    '* paste file *
    '**************
    MaSel = CATIA.ActiveEditor.Selection
    MaSel.Clear()
    MaSel.Add(MyOutObj)
    MaSel.Paste()


End Sub

Be carefull : there isn't any error gestion