Reply

Help to program in VC++ with solid edge

[ Edited ]

 

solid edge programming in VC++ help

 

Posted by: Gayathri madireddy
Post date: 2/11/2009 12:06:07 AM

7 REPLIES

RE: Help to program in VC++ with solid edge

[ Edited ]

I believe there are a few of us here than that answer C++ questions.

 

Posted by: Jason Newell
Post date: 2/11/2009 6:37:10 AM

RE: Help to program in VC++ with solid edge

[ Edited ]

HI,

 

I'm just writing an application in C++.

 

Not easy as working in C# or VB NET, especially for the lack of OOB examples.

 

Regards

 

Massimo

 

Posted by: Massimo Magris
Post date: 2/11/2009 6:57:27 AM

RE: Help to program in VC++ with solid edge

[ Edited ]

Hi Massimo,

Can you please send an example to create a line in solid edge usins VC++.

Thank you very much in advance.

 

Gayathri

 

Posted by: Gayathri madireddy
Post date: 2/11/2009 4:06:20 PM

RE: Help to program in VC++ with solid edge

[ Edited ]

 

Here is an example from the new Solid Edge ST Programmers Guide.  I know it's not in C++ but it should give you a good idea of how to go about it.using SolidEdgeConstants;using System;using System.Reflection;using System.Runtime.InteropServices;namespace MyMacro{ class Program { static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument part = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.RefPlanes refplanes = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; System.Array aProfiles = null; try { // Connect to a running instance of Solid Edge application = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application"); // Get a reference to the documents collection documents = application.Documents; // Create a new part document part = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument", Missing.Value); // Get a reference to the profile sets collection profileSets = part.ProfileSets; // Add a new profile set profileSet = profileSets.Add(); // Get a reference to the profiles collection profiles = profileSet.Profiles; // Get a reference to the ref planes collection refplanes = part.RefPlanes; // Add a new profile profile = profiles.Add(refplanes.Item(3)); // Get a reference to the lines2d collection lines2d = profile.Lines2d; // Draw the Base Profile lines2d.AddBy2Points(0, 0, 0.08, 0); lines2d.AddBy2Points(0.08, 0, 0.08, 0.06); lines2d.AddBy2Points(0.08, 0.06, 0.064, 0.06); lines2d.AddBy2Points(0.064, 0.06, 0.064, 0.02); lines2d.AddBy2Points(0.064, 0.02, 0.048, 0.02); lines2d.AddBy2Points(0.048, 0.02, 0.048, 0.06); lines2d.AddBy2Points(0.048, 0.06, 0.032, 0.06); lines2d.AddBy2Points(0.032, 0.06, 0.032, 0.02); lines2d.AddBy2Points(0.032, 0.02, 0.016, 0.02); lines2d.AddBy2Points(0.016, 0.02, 0.016, 0.06); lines2d.AddBy2Points(0.016, 0.06, 0, 0.06); lines2d.AddBy2Points(0, 0.06, 0, 0); // Define Relations among the Line objects to make the Profile closed relations2d = (SolidEdgeFrameworkSupport.Relations2d) profile.Relations2d; relation2d = relations2d.AddKeypoint( lines2d.Item(1), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(2), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(3), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(4), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(5), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(6), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(6), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(7), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(7), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(8), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(8), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(9), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(10), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(11), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(11), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(12), (int)KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint( lines2d.Item(12), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)KeypointIndexConstants.igLineStart, true); // Close the profile profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Hide the profile profile.Visible = false; // Create a new array of profile objects aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); // Get a reference to the models collection models = part.Models; // Create the extended protrusion. model = models.AddFiniteExtrudedProtrusion( aProfiles.Length, ref aProfiles, SolidEdgePart.FeaturePropertyConstants.igRight, 0.05, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { if (model != null) { Marshal.ReleaseComObject(model); model = null; } if (models != null) { Marshal.ReleaseComObject(models); models = null; } if (line2d != null) { Marshal.ReleaseComObject(line2d); line2d = null; } if (lines2d != null) { Marshal.ReleaseComObject(lines2d); lines2d = null; } if (relation2d != null) { Marshal.ReleaseComObject(relation2d); relation2d = null; } if (relations2d != null) { Marshal.ReleaseComObject(relations2d); relations2d = null; } if (refplanes != null) { Marshal.ReleaseComObject(refplanes); refplanes = null; } if (profile != null) { Marshal.ReleaseComObject(profile); profile = null; } if (profileSet != null) { Marshal.ReleaseComObject(profileSet); profileSet = null; } if (profileSets != null) { Marshal.ReleaseComObject(profileSets); profileSets = null; } if (part != null) { Marshal.ReleaseComObject(part); part = null; } if (documents != null) { Marshal.ReleaseComObject(documents); documents = null; } if (application != null) { Marshal.ReleaseComObject(application); application = null; } } } }}

 

Posted by: Jason Newell
Post date: 2/11/2009 8:32:20 PM

RE: Help to program in VC++ with solid edge

[ Edited ]

Thanks for ur response.

I already have the program in C# and .net,but i need sample source code in C++.

PLease let me know about this..

 

Thanks,

Gayathri

 

Posted by: Gayathri madireddy
Post date: 2/11/2009 9:55:49 PM

RE: Help to program in VC++ with solid edge

[ Edited ]

// stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//#pragma once// Modify the following defines if you have to target a platform prior to the ones specified below.// Refer to MSDN for the latest info on corresponding values for different platforms.#ifndef WINVER // Allow use of features specific to Windows XP or later.#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.#endif#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.#endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.#endif#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.#endif#include #include #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit#include #include #pragma warning( disable : 4278 )#pragma warning( disable : 4146 )// TODO: reference additional headers your program requires here// Solid Edge API#import "libid:8A7EFA3A-F000-11D1-BDFC-080036B4D502" exclude ("UINT_PTR", "LONG_PTR")using namespace SolidEdgeFramework;#import "libid:943AC5C6-F4DB-11D1-BE00-080036B4D502"using namespace SolidEdgeFrameworkSupport;#import "libid:3E2B3BE1-F0B9-11D1-BDFD-080036B4D502"using namespace SolidEdgeGeometry;#import "libid:8A7EFA42-F000-11D1-BDFC-080036B4D502"using namespace SolidEdgePart;#pragma warning( default : 4146 )#pragma warning( default : 4278 )

 

 // MyMacro.cpp : Defines the entry point for the console application.//#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); SolidEdgeFramework::ApplicationPtr pApplication = NULL; SolidEdgeFramework:Smiley Very HappyocumentsPtr pDocuments = NULL; SolidEdgePart:Smiley TongueartDocumentPtr pPartDocument = NULL; SolidEdgePart:Smiley TonguerofileSetsPtr pProfileSets = NULL; SolidEdgePart:Smiley TonguerofileSetPtr pProfileSet = NULL; SolidEdgePart:Smiley TonguerofilesPtr pProfiles = NULL; SolidEdgePart:Smiley TonguerofilePtr pProfile = NULL; SolidEdgePart::RefPlanesPtr pRefPlanes = NULL; SolidEdgeFrameworkSupport::Lines2dPtr pLines2d = NULL; SolidEdgeFrameworkSupport::Line2dPtr pLine2d = NULL; pApplication.GetActiveObject(_T("SolidEdge.Application")); pDocuments = pApplication->Documents; pPartDocument = pDocuments->Add(_T("SolidEdge.PartDocument")); pProfileSets = pPartDocument->ProfileSets; pProfileSet = pProfileSets->Add(); pRefPlanes = pPartDocument->RefPlanes; pProfiles = pProfileSet->Profiles; pProfile = pProfiles->Add(pRefPlanes->Item((LONG)3)); pLines2d = pProfile->Lines2d; pLine2d = pLines2d->AddBy2Points(0, 0, 0.08, 0); pLine2d = pLines2d->AddBy2Points(0.08, 0, 0.08, 0.06); pLine2d = pLines2d->AddBy2Points(0.08, 0.06, 0.064, 0.06); pLine2d = pLines2d->AddBy2Points(0.064, 0.06, 0.064, 0.02); pLine2d = pLines2d->AddBy2Points(0.064, 0.02, 0.048, 0.02); pLine2d = pLines2d->AddBy2Points(0.048, 0.02, 0.048, 0.06); pLine2d = pLines2d->AddBy2Points(0.048, 0.06, 0.032, 0.06); pLine2d = pLines2d->AddBy2Points(0.032, 0.06, 0.032, 0.02); pLine2d = pLines2d->AddBy2Points(0.032, 0.02, 0.016, 0.02); pLine2d = pLines2d->AddBy2Points(0.016, 0.02, 0.016, 0.06); pLine2d = pLines2d->AddBy2Points(0.016, 0.06, 0, 0.06); pLine2d = pLines2d->AddBy2Points(0, 0.06, 0, 0); pLine2d = NULL; pLines2d = NULL; pRefPlanes = NULL; pProfile = NULL; pProfiles = NULL; pProfileSet = NULL; pProfileSets = NULL; pPartDocument = NULL; pDocuments = NULL; pApplication = NULL; CoUninitialize(); return 0;}

 

Posted by: Jason Newell
Post date: 2/12/2009 7:10:15 AM

RE: Help to program in VC++ with solid edge

[ Edited ]

Thank you for the reply.

I could able to get sketch using your code which u have sent.

I am trying to protrude the sketch using AddFiniteExtrudedProtusion method,but i am facing problem in creating SAFEARRAY (2ndArugument).i am creating safearray and storing the pointers but still unable to get Protrusion....

 

Posted by: Gayathri madireddy
Post date: 2/15/2009 10:25:32 PM