5 Replies Latest reply on Sep 15, 2014 12:49 PM by andrew_french

    Automation DxDesigner VB.NET question




      When I try to write a VB.NET applikation for usage of DxDesigner (EE7.9.5) I get following error message inside VB.NET.



      With VBScript this line does not make any problems.


      What am I doing wrong?


      Thanks alot


        • 1. Re: Automation DxDesigner VB.NET question

          I think that data object IStringList does not exist in the COM object, but I'd need to see the error message in English to be sure.  Can you translate that?


          There is probably something very similar available in the COM that will do the same thing.  Slightly different name, most likely.

          • 2. Re: Automation DxDesigner VB.NET question

            The expression has the type "ViewDraw.IStringList" and is not a collection.

            • 3. Re: Automation DxDesigner VB.NET question

              There are a number of objects we would normally think of as collections which the Mentor automation tools do not treat as such.  I have no idea why, and there is no rhyme or reason (that I have found) to which are and which are not.  In these cases, it is necessary to attempt to declare them as ViewDraw.IVDObjects, as System.Object, or with no data type at all.  In that order.


              It usually works even with no data type, because in every case that I can remember, the single object you are going to iterate can be typed successfully and the appropriate functionality will be available on it. Such as with a for each thing in things, thing can be typed correctly.


              For example, there is no ViewDraw.Nets type, but there is a ViewDraw.Net type. So if you want to iterate a group of nets, first collect them into an untyped variable nets, then iterate with a for each net in nets loop. For example:


                      Dim nets

                      Dim net As ViewDraw.Net

                      Dim name As String


                      name = app.GetProjectData.GetiCDBDesignRootBlock(app.GetActiveDesign())


                      nets = app.DesignNets("", name, "-1", , False)


                      For Each net In nets

                             'do stuff on each net here



              Try this and see what you come up with.

              • 4. Re: Automation DxDesigner VB.NET question

                ViewDraw.IStringList does not implement IEnumerable, so you can't use For Each...Next. Here's an extension method that will allow it:


                Module Extensions
                    Public Iterator Function ToEnumerable(ByVal collection As ViewDraw.IStringList) As IEnumerable(Of String)
                        For i As Integer = 1 To collection.GetCount()
                            Yield collection.GetItem(i)
                    End Function
                End Module


                And here's how to use it:


                Module Module2
                    Sub Main()
                        Dim app As ViewDraw.Application
                        app = GetObject(, "ViewDraw.Application")
                        For Each schematic In app.SchematicSheetDocuments.GetAvailableSchematics.ToEnumerable()
                    End Sub
                End Module


                Like Patrick said, there are other ViewDraw objects that unfortunately don't implement IEnumerable (e.g. IVdObjs). You can make the extension method generic, but I'd probably add an extension method per collection type.

                • 5. Re: Automation DxDesigner VB.NET question



                  I've always just done something like this


                  Dim netObj As ViewDraw.IVdObjs

                  Dim net As ViewDraw.Net


                  netObj = VdApp.Query(ViewDraw.VdObjectTypeMask.VDM_NET, ViewDraw.VdAllOrSelected.VD_ALL)



                                  For z = 1 To netObj.Count


                                      net = netObj.Item(z)