Reply

Base Feature

[ Edited ]

 

I have sheetmetal with a flat pattern. I want to save the flat pattern to a separate file and create a base feature from the part copy.

This gives a error message with the follwing error message {System.InvalidCastException: Interface not supported (Exception of HRESULT: 0x80004002 (E_NOINTERFACE))

Can someone point me in the right direction?

 privatevoid Test()Application app = null;;Documents documents = null;SheetMetalDocument sheetmetal = null;Models models = null;Model model = null;Constructions constructions = null;FlatPatternModels flatpatternmodels = null;FlatPatternModel flatpatternmodel = null;try

{

 // Connect to a running instance of Solid Edge

app = (SolidEdgeFramework.

 

app.DisplayAlerts =

 Application)Marshal.GetActiveObject("SolidEdge.Application");false;// to be sure it is a sheet metal document

 

{

sheetmetal = (SolidEdgePart.

 

{

flatpatternmodels = (SolidEdgePart.

 

{

flatpatternmodel = flatpatternmodels.Item(1);

 

{

flatpatternmodel.SaveBody(

SolidEdgeConstants.

SolidEdgeConstants.

 if (app.ActiveEnvironment == "SheetMetal")SheetMetalDocument)app.ActiveDocument;if (sheetmetal != null)FlatPatternModels)sheetmetal.FlatPatternModels;if (flatpatternmodels != null)if (flatpatternmodel != null)"c:\\tmp.psm",DocumentTypeConstants.igPartDocument,ParasolidVersionConstants.seParasolidCurrentVersion);// Get the documents collection.

documents = (SolidEdgeFramework.

documents.Open(

 

sheetmetal = (SolidEdgePart.

models = (SolidEdgePart.

 

{

constructions = (SolidEdgePart.

 

{

 

models.AddByConstruction(constructions.Item(1)); 

}

}

}

}

}

}

}

 

{

 

}

 Documents)app.Documents;"c:\\tmp.psm", Missing.Value, Missing.Value, Missing.Value,Missing.Value, Missing.Value);SheetMetalDocument)app.ActiveDocument;Models)sheetmetal.Models;if (models != null)Constructions)sheetmetal.Constructions;if (constructions != null)catch (Exception ex)MessageBox.Show(ex.Message);finally

{

app.DisplayAlerts =

 

{

 

documents =

}

 

{

 

sheetmetal =

}

 

{

 

models =

}

 

{

 

model =

}

 

{

 

app =

}

}

}true;if (documents != null)Marshal.ReleaseComObject(documents);null;if (sheetmetal != null)Marshal.ReleaseComObject(sheetmetal);null;if (models != null)Marshal.ReleaseComObject(models);null;if (model != null)Marshal.ReleaseComObject(model);null;if (app != null)Marshal.ReleaseComObject(app);null;

 

{

SolidEdgeFramework.

SolidEdgeFramework.

SolidEdgePart.

SolidEdgePart.

SolidEdgePart.

SolidEdgePart.

SolidEdgePart.

SolidEdgePart.

 

 

Posted by: Rob Flippo
Post date: 9/9/2009 9:23:56 PM

1 REPLY

RE: Base Feature

[ Edited ]

 

The code was not readable, this time correctly formatted. 

privatevoid Test()

{

SolidEdgeFramework.Application app = null;;

SolidEdgeFramework.Documents documents = null;

SolidEdgePart.SheetMetalDocument sheetmetal = null;

SolidEdgePart.Models models = null;

SolidEdgePart.Model model = null;

SolidEdgePart.Constructions constructions = null;

SolidEdgePart.FlatPatternModels flatpatternmodels = null;

SolidEdgePart.FlatPatternModel flatpatternmodel = null;

try

{

  // Connect to a running instance of Solid Edge

  app = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application");

  app.DisplayAlerts = false;

  // to be sure it is a sheet metal document

  if (app.ActiveEnvironment == "SheetMetal")

  {

    sheetmetal = (SolidEdgePart.SheetMetalDocument)app.ActiveDocument;

    if (sheetmetal != null)

    {

       flatpatternmodels = (SolidEdgePart.FlatPatternModels)sheetmetal.FlatPatternModels;

       if (flatpatternmodels != null)

       {

          flatpatternmodel = flatpatternmodels.Item(1);

          if (flatpatternmodel != null)

          {

             flatpatternmodel.SaveBody("c:\\tmp.psm", SolidEdgeConstants.DocumentTypeConstants.igPartDocument, SolidEdgeConstants.ParasolidVersionConstants.seParasolidCurrentVersion);

             // Get the documents collection.

             documents = (SolidEdgeFramework.Documents)app.Documents;

             documents.Open("c:\\tmp.psm", Missing.Value, Missing.Value, Missing.Value,Missing.Value, Missing.Value);

             sheetmetal = (SolidEdgePart.SheetMetalDocument)app.ActiveDocument;

             models = (SolidEdgePart.Models)sheetmetal.Models;

             if (models != null)

             {

               constructions = (SolidEdgePart.Constructions)sheetmetal.Constructions;

               if (constructions != null)

               {

                 models.AddByConstruction(constructions.Item(1)); 

               }

             }

           }

         }

       }

     }

   }

   catch (Exception ex)

   {

      MessageBox.Show(ex.Message);

   }

   finally

   {

     app.DisplayAlerts = true;

     if (documents != null)

     {

       Marshal.ReleaseComObject(documents);

       documents = null;

     }

     if (sheetmetal != null)

     {

       Marshal.ReleaseComObject(sheetmetal);

       sheetmetal = null;

     }

     if (models != null)

     {

       Marshal.ReleaseComObject(models);

       models = null;

     }

     if (model != null)

     {

       Marshal.ReleaseComObject(model);

       model = null;

     }

     if (app != null)

     {

       Marshal.ReleaseComObject(app);

       app = null;

     }

   }

 }

 

 

Posted by: Rob Flippo
Post date: 9/10/2009 11:01:15 PM