ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
NGNadav Gover01/08/2017

I have a problem getting the ActiveDoc function to work, using SolidWorks 2017.

I have this piece of code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using AutoPallet3D;

using SolidWorks;

using Microsoft.VisualBasic;

using System.Collections;

using SolidWorks.Interop.sldworks;

using System.Runtime.InteropServices;

namespace SolidTest3

{

    public class Solidmmm

    {

        ModelDoc2 swModel;

        public Solidmmm()

        {

            var x = new SolidWorksController(@"C:\Users\Nadavgo\Downloads\", @"C:\Users\Nadavgo\Downloads\", false);

            x.LaunchOrConnectToSolidWorks();

            x.SetSolidWorksVisibility(true, true);

            var doc = x.CreateDocument();

            swModel = (ModelDoc2)swApp.ActivateDoc;     // Error 4 Cannot convert method group 'ActivateDoc' to non-delegate type                                                                                           'SolidWorks.Interop.sldworks.ModelDoc2'.      

            x.CloseSolidworks();

        }

        public SldWorks swApp;

    }   

}

The red line causes trouble and the error is commented.

The 4 lines before the red line just opens up SolidWorks and opens up a new part.

For now, I just need to get this active part I just opened and let's say, draw a circle for example.

Does anyone know how to get this ActiveDoc work?

Thanks