4 Replies Latest reply on Oct 24, 2018 3:25 AM by Peter Brinkhuis

    What is the significance of the 'I' prefix on some properties and methods? ex: "ActiveDoc" vs "IActiveDoc".

    Matthew Lasorsa

      Within a given library I've noticed there are often duplicate properties or methods with an 'I' prefix.  For example, under the SldWorks library there is both "ActiveDoc" and "IActiveDoc".  The only difference I see between them in the object browser within Microsoft VBA is that ActiveDoc is described as "Property ActiveDoc As Object", whereas IActiveDoc (and IActiveDoc2) is described as "Property IActiveDoc As ModelDoc"  (or "Property IActiveDoc2 As ModelDoc2").  What is the difference between these two?  Any rule of thumb on when to select one over the other?


      For reference, I'm very new to Solidworks API programming.  I do have some basic programming experience with Matlab, C++, Arduino, and using VBScript to automate other design software.  I'm eager to learn more about automation so any help is greatly appreciated.  I have a copies of 'WSH and VBScript Programming for the Absolute Beginner (4th ed.) - Jerry Lee Ford' and 'Automating SOLIDWORKS 2017 Using Macros - Mike Spens' at my disposal if referencing either of these texts allows for an easier response.



      If it's of any interest, the script I'm working on is below.  My end goal is to be able to set reference plane locations based on simple user input.  Next I'll need to import a different layer from a DXF file onto each of these reference planes as a sketch, and then perform various extrusions and cuts to create a printed circuit board.  Right now the script is far from this point as I'm just trying to learn the basics.  I've already discovered there's no functionality to import specific layers from a DXF so I'm already looking into a work around for this.  I'm including this for context behind my question, but if there are any unrelated comments I'm all ears.


      Option Explicit

      Dim objSWApp As Object

      Dim blnStatus As Boolean

      Dim lngStatus As Long, lngWarnings As Long, lngErrors As Long


      Sub main()


      Set objSWApp = Application.SldWorks


      Dim objPCB As Object

      Set objPCB = objSWApp.ActiveDoc


      blnStatus = objPCB.Extension.SelectByID2("Top", "PLANE", 0, 0, 0, False, 0, Nothing, 0)


      'Dim strFileName As String

      'strFileName = " **omitted for privacy purposes** "


      'Dim objBaseLameFeature As Object

      'Set objBaseLameFeature = objPCB.FeatureManager.InsertDwgOrDxfFile(strFileName)



      '''Dim objBaseLameFeature As Object

      '''Set objBaseLameFeature = objPCB.FeatureManager.InsertDwgOrDxfFile(strFileName)

      '''blnStatus = objPCB.EditRebuild3()

      '''blnStatus = objPCB.Extension.SketchBoxSelect("0.012012", "-0.024279", "0.000000", "-0.014004", "0.010832", "0.000000")

      '''objPCB.SketchAddConstraints "sgFIXED"

      '''objPCB.ClearSelection2 True

      '''objPCB.SketchManager.InsertSketch True

      '''blnStatus = objPCB.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)


      '''' Named View

      '''objPCB.ShowNamedView2 "*Trimetric", 8


      '''Set objBaseLameFeature = objPCB.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.001465, 0.01, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)

      '''objPCB.SelectionManager.EnableContourSelection = False


      End Sub