Guys, I need help in inserting a part into a part document
When I debug the code, it throws an error.
I've attached screen shots for your reference
Can you please help me
Thanks in advance
dim instance as new partdoc seams wrong to me
I suppose that you want to create new empty part: 2017 SOLIDWORKS API Help - NewDocument Method (ISldWorks)
No ma'am that is not what I want to create
I want to insert two different solidpart files in one document.
Its like the boolean operation where you superimpose two parts and figure out the common area between them.
(Insert--Part-- choose part command in solidworks)
dim instance as new partdoc is wrong anyway
or you need to open first doc
2017 SOLIDWORKS API Help - OpenDoc6 Method (ISldWorks)
or you have to use activedoc
2017 SOLIDWORKS API Help - ActiveDoc Property (ISldWorks)
I think issue in Dim Instance as New PartDoc.
Please try it like this.
static void Main(string args)
SldWorks SwApp = (SldWorks)System.Runtime.InteropServices.Marshal.GetActiveObject("sldworks.Application");
PartDoc SwModel = SwApp.NewPart();
Dim swApp As SldWorks.SldWorks
Dim swpart As SldWorks.PartDoc
Set swApp = Application.SldWorks
Set swpart = swApp.NewPart
swpart.InsertPart2 "C:\Users\MBB2\Desktop\FM\Ctyl.SLDPRT", swInsertPartOptions_e.swInsertPartImportSolids
Thanks Manikandan Babu!!!. Your example code worked
Retrieving data ...