Copy sketch



Hello all,

I am using SolidEdgeST and have such trouble.

I am trying to copy sketch from top assembly to part in subassembly

I am abble to make associative copy of sketch from top assembly directly to part in top assembly or to subassembly. But I am

 not abble to make associative copy of sketch from top assembly to part in subassembly. It seems to be easy and it works

manually but using program I am only abble to create non-associative copy.

I unsuccessfuly tried several approaches:

- copy sketch directly

- copy sketch to subassembly and then copy sketch from subassem to part

- copy sketch to subassembly and then switch subassembly to "Edit" state and copy from subassem to part

- switch part to "Edit" state and copy sketch (which is probably nonsence)

- I tried to call saving of assemblies and updating of assemblies

- I checked ...CommandConstants to use native copiing instead of automation method but I did not find it

and only result is that I am abble to make non-associative copy of sketch

You can find attached simple project and assembly for tests.

If you have any idea how to break that trouble or make some workaround please let me know.


SolidEdgeFramework.Application application;

if ((application = (SolidEdgeFramework.Application)

  Marshal.GetActiveObject("SolidEdge.Application")) != null)




    SolidEdgeAssembly.AssemblyDocument topAssem =


    SolidEdgeAssembly.Layout topAssemLayout =


    //SolidEdgeAssembly.Occurrence topPartOcc =



    SolidEdgeAssembly.Occurrence subAssemOcc =


    SolidEdgeAssembly.AssemblyDocument subAssem =


    //SolidEdgeAssembly.Layout subAssemLayout =


    SolidEdgeAssembly.Occurrence subPartOcc =


    System.Object errorStatus;

    topAssem.CopySketch(topAssemLayout, subPartOcc, true, out errorStatus);

    int aa = 0;








Best Regards,



Posted by: Jara Ctverak
Post date: 10/27/2009 1:59:37 AM


RE: Copy sketch



the second argument of CopySketch is only an Occurence object, if it is an occurrence of the top level assembly, but should be a Reference to your occurrence, if it is at any lower level. If your occurrence is more than 1 level deep, you have to recursivly create references bottom-up from your occurrence until the top level assembly:


Here is some untested code based on your example. I haven't looked into your attachments yet:


Reference refToPart = topAssem.CreateReference(subAssemOcc, subPartOcc);

topAssem.CopySketch(topAssemLayout, refToPart, true, out errorStatus)



Posted by: Martin Bernhard
Post date: 10/28/2009 7:49:50 AM

RE: Copy sketch


Hello Martin!

Thank you, it works!

Best Regards,




Posted by: Jara Ctverak
Post date: 10/29/2009 4:14:01 AM