DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Unstable / Erratic performance of the "Function GetPoints".

Started by Pavlos, July 16, 2014, 05:30:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pavlos

I am working on a general Naval Architecture program, intending eventually to develop a specialised Tool Bar that will automate most Naval Architecture basic Lines Plan Drawing tasks and Compute thereof Hydraustatic Particulars, Bonjean Curves Data, Cross Curves of Stability using Cartesian Coordinates and then using Polar Coordinates, (Atwood's Method).  I am using Visual Basic 2010 Express Edition and my computer runs on Windows 7 Home Premium.

Declarations at Module Level:
Public DcEnt_PoopFwdEndCasing As DesignCAD.Entity
All other variables hereunder are declared at Module level like the above.  Only I, K are declared locally at the relevant Sub

        If HPDcl > 0 Then
            DcPts.SetCommandPoint(Xpdc_AE, 0, Zpdc_AE)
            DcPts.SetCommandPoint((Xpdc_AE + Xpds_AE) / 2, Ypds_AE / 2, Zpdc_AE - (Ypds_AE / 2) * Mcmbp)
            DcPts.SetCommandPoint(Xpds_AE, Ypds_AE, Zpds_AE)
            DcPts.SetCommandPoint(Xpds_AE, Ypds_AE, Zpds_AE)
            For I = 1 To Imax / 2
                If X(I) > Xpd_FE Then Exit For
                Xx = X(I) : Yy = Ypds(I) : Zz = Zpds(I)
                DcPts.SetCommandPoint(Xx, Yy, Zz)
            Next I
            DcPts.SetCommandPoint(Xpd_FE, Ypds_FE, Zpds_FE)
            DcPts.SetCommandPoint(Xpd_FE, Ypds_FE, Zpds_FE)
            DcPts.SetCommandPoint(Xpd_FE, Ypds_FE / 2, Zpdc_FE - (Ypds_FE / 2) * Mcmbp)
            DcPts.SetCommandPoint(Xpd_FE, 0, Zpdc_FE)
            DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DcCurve.Draw)

            ImaxPoopAtSide = DcEnt_PoopDeckAtS.PointsCount        'Determine the number of points stored in DcEnt_PoopDeckAtS.
            ReDim PoopDkAtSide_XYZarray(3 * ImaxPoopAtSide)     'Resize the PoopDkAtSide_XYZarray to store the points' coordinate data.
            PointsRetrieved = DcEnt_PoopDeckAtS.GetPoints(1, ImaxPoopAtSide, PoopDkAtSide_XYZarray)    'Fill in the Array.
            Debug.Print("Poop Dk At Side Coordinate Array")
            Debug.Print("Number of Poop Dk At Side Points: " & ImaxPoopAtSide)
            Debug.Print("Points Retrieved by the GetPoints Method: " & PointsRetrieved)
            I = 0   'This is simply to take a look at the points relevant coordinates stored in the Array.  Array Index starts ar "0" not "1".
            Do Until I = ImaxPoopAtSide
                Xx = PoopDkAtSide_XYZarray(3 * I) : Yy = PoopDkAtSide_XYZarray(3 * I + 1) : Zz = PoopDkAtSide_XYZarray(3 * I + 2)
                Debug.Print(I & " *** " & Xx & " /// " & Yy & " /// " & Zz)
                I = I + 1
            Loop
        End If

While DcEnt_PoopDeckAtS draws the curve, and while the rest of the code performed well a great many times, after some minor changes elsewhere in the code, suddenly DcEnt_PoopDeckAtS  throws a NullReferenceException.  This happened with several other parts of the program forcing to create and populate the necessary arrays from the ground up, i.e. without making use of the "Function GetPoints". 

In the last run, after "DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DcCurve.Draw)" drew the curve to perfection, the program stopped at the "ImaxPoopAtSide = DcEnt_PoopDeckAtS.PointsCount"    giving "NullReferenceException was unhandled".  Apparently after the curve is drawn, DcEnt_PoopDeckAtS = Nothing.  I cannot use the ""New"  keyword because when I try I get an error stating "DesignCAD.EntityClass.Friend Sub(New)'is not accessible in this context because it is 'Friend' ".    I do not know how else I can create an instance of the object "DcEnt_PoopDeckAtS".

The following Sub initiates DesignCAD in the module.

    'START AND SET UP DESIGN CAD 3D INTERFACE
    Sub SetUpDesignCAD3D()
        DcApp = New DesignCAD.Application
        DcDocs = DcApp.Documents
        DcApp.Visible = True
        DcDoc = DcDocs.Add 
        DcDoc.DraftingMode = False
        DcDoc.ActiveView.Application.Maximize()
        DcViews = DcDoc.Views
        DcMark = DcDoc.PointMark
        DcPts = DcDoc.CmdPoints
        DcLine = DcDoc.Line
        DcLineStyle = DcDoc.LineStyle
        DcArc = DcDoc.Arc
        DcCurve = DcDoc.Curve
        DcPlane = DcDoc.Plane
        DcSurf = DcDoc.Surface
        DcSelection = DcDoc.Selection
        DcSolid = DcDoc.Solid
        DcTrim = DcDoc.Trim
        DcEnts = DcDoc.Entities
        DcLayers = DcDoc.Layers

I will appreciate any help I can get.  Otherwise I will have to recode the program in a manner that will eliminate entirely the use of the "Function GetPoints".

Regards
Pavlos




Pavlos

prl

Pavlos,

Unfortunately besides Dt (Administrator), I don't know of anyone that knows the VB OLE.   If you are crunching math, basiccad will do that for you also.  And you can use VB to build the GUI to run the various basiccad programs.

Sorry I can't be more helpful. 

Pavlos

Unfortunately it is not only number crunching.  I am using DesignCAD 23 to derive the data I will be using for the computations.  In other words, I tell DesignCAD how to read and draw a ship's Line's Plan to perfection, based on minimum amount of offset data, and without ever using Solid Object Generation, (i.e. using only 3D Linear Geometry like if it would have been drawn by hand on drawing board, so many years ago), and then by using various types of intersections, I derive all the data that is required to calculate Hydraustatic Particulars, Cross Curves of Stability, Draw a Capacity Plan, etc.

I am not a professional programmer, but I have good Naval Architecture Drawing background dating back to the times when drawings were done manually, and the required data had to be derived from such drawings by an excruciating time consuming process, usually by two persons.  As my other consultancy work does not allow the time to indulge in the old ways and as the old ways are only as good as the time that is put into their practice, whenever I get some free time, I try to transfer all such experiences into software, that will not depend on how good an artist or draftsman will need to be, in order to generate a certain result from such drawings.  Therefore I am  afraid I will need to stick to VB 2010 in order to make as much use of my prior VB6 experience.

I only hope that Dt (Administrator) can come up with some explanation that I can implement.  Otherwise I will have to fill in the XYZ arrays the old fashion way.

Thanks for your interest.
Best Regards
Pavlos

     
Pavlos

prl

I understand.

But I've never know a situation where BasicCAD could not do everything the OLE does with the exception of GUI things.  In other words, if you are generating objects, reading from them and computing new things, BasicCAD will be the faster of the two and certainly more easily debugged.  The OLE rarely offers any advantages unless you are creating dialogs and user interface items (pretty stuff).  Because of this, I create hybrid applications where the GUI is OLE driven and the OLE runs basiccad programs because of the speed.  OLE is terribly slow at getting and sending data.

Pavlos

Many thanks for you advise which I will certainly look into it in my next programming project.  Some 10 years ago when I got my first DesignCAD 3D (it was version 12 I think), I was using BASICA as programming tool.  I took a close look at the DesignCAD Developer's Toolkit and I found the programming options therein somewhat intimidating for use by an amateur.  I then took a look at the programming environment of VB6 and I was hooked.  I therefore did a lot of programming with VB6 and also VBA in Excel.  This is why when I decided to revamp all my old work, I went straight to VB 2008 Express first, but vary quickly thereafter, (because of some complications encountered with Data Base Applications), I shifted straight to VB 2010 Express Edition.

Best Regards
Pavlos

P.S.  Looking at my problem again it would appear that perhaps the issue may not be an instability in the performance of the "Function GetPoints", but at the sudden and unjustified return of "Nothing" in the
  DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DcCurve.Draw), after the relevant Poop Deck Line has been drawn to perfection.

I believe that if DcEnt_PoopDeckAtS does not return "Nothing" after the said curve has been drawn, then I can see no reason why
ImaxPoopAtSide = DcEnt_PoopDeckAtS.PointsCount   and
   PointsRetrieved = DcEnt_PoopDeckAtS.GetPoints(1, ImaxPoopAtSide, PoopDkAtSide_XYZarray) will not work.

If anybody has any ideas I will be most grateful.


     
Pavlos

prl

Quote from: Pavlos on July 18, 2014, 08:28:40 AM
P.S.  Looking at my problem again it would appear that perhaps the issue may not be an instability in the performance of the "Function GetPoints", but at the sudden and unjustified return of "Nothing" in the
  DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DcCurve.Draw), after the relevant Poop Deck Line has been drawn to perfection.

Delphi (Pascal) would not let me code it the way you have.  You are passing a constant object as a variable parameter (Delphi being highly typed).

Try this: (syntax is Pascal, but close enough)

EntityID := DcCurve.Draw;
DcEnt_PoopDeckAtS := DcEnts.GetEntityByID(EntityID);

where EntityID is defined as an OleVariant

By the way, if you gave me the values for your variables, I could easily code that portion of your code in BasicCAD.  You might find it interesting to compare. 

Edit:  Can you tell  I like BasicCAD?  :)

DrollTroll

Hi Pavlos,

Please see this note regarding Entity IDs in .NET languages:
http://forum.designcad.com/index.php?topic=5074.0

The OLE Automation SDK was designed with pre-.NET VB6 in mind. Some of the newer VB syntax is not completely compatible.

Also, while debugging this, I suggest always performing each operation as a separate line of code, rather than nesting them together as you have some of them here. For example, I'd change

DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DcCurve.Draw)

to
Dim CID as Decimal
CID = DcCurve.Draw
DcEnt_PoopDeckAtS = DcEnts.GetEntityByID(DecimalToOACurrency(CID))

Note that the above is off the top of my head, and I haven't actually coded a test run yet.

Also, I'm moving this discussion to the SDK boards.
DT
25 years with DesignCAD

Pavlos

High everybody and thank you all for your interest.

I have tried several variations of the type posted by prl (in Pascal Equivalent), but in in VB 2010.  Unfortunately it did not work.

EntityID := DcCurve.Draw;
DcEnt_PoopDeckAtS := DcEnts.GetEntityByID(EntityID);

I have also tried VB 2010 equivalent to that posted by DrollTroll but also it did not work.

The problem seemed to be centred in the "Nothing" returned by the "DcEnt_PoopDeckAtS", after the relevant curve gets drawn perfectly well.  I have therefore decided to backtrack to the version of the code when "DcEnt_PoopDeckAtS" did not return "Nothing".  I then shifted all the additions and modifications that were made, to a location well after the relevant array has been harvested.  I am happy to announce that now the problem is solved and the code runs perfectly well drawing all the parts of the ship and storing the relevant coordinates in an Excel file.

For some unidentified reason, if the part of the code containing the "DcEnt_PoopDeckAtS" expression works and the relevant array becomes available, we must not try to make any alterations or additions before the section where it becomes active within the Sub containing it.

In three other areas of the program that were much more complex, when this exception kicked in, I had to resort to traditional coding, in order to generate the necessary arrays. I hope the area of the code now resolved will not crash later when I try all the final variations at the end, namely hull without cruiser stern, Without Poop, Without Forecastle, or without both.

Best Regards
Pavlos
   




 
Pavlos

prl

Quote from: Pavlos on July 22, 2014, 08:12:31 AM
The problem seemed to be centred in the "Nothing" returned by the "DcEnt_PoopDeckAtS", after the relevant curve gets drawn perfectly well.

Well in Delphi, the next question would be where in your code have you type declared DcEnt_PoopDeckAtS?  In Delphi you have to declare a variable before you initialize it in the procedure code.  No automatic declaring and nil initialization in the procedure.  So at the procedure level (I think you call them subs), it could be declared locally as var DcEnt_PoopDeckAtS, DcEnt; where DcEnt is globally type declared in the interface section (linked to the DesignCAD_TLB.Entity Type Library Binary).


MAYBE in VB it would be something like this (imposing Delphi rules)

Option Explicit
Public DcEnt As DesignCAD.IDcadEntity

.
.
.

then in your subs

dim DcEnt_PoopDeckAtS as DcEnt




Pavlos

In VB 2010 "Option Explicit" is rendered implicit when the project options are set up.  In the module I am using all variables name are declared as Public at Module level, as shown in the following:

Module Module1
    'VARIABLES LOCATING PROGRAM ON THE HOST COMPUTER
    Public InputData As String, OutputData As String, StartUpPath As String
    'MS EXCEL INTERFACE VARIABLES
    Public XLapplication As Microsoft.Office.Interop.Excel.Application
    Public XLbooks As Microsoft.Office.Interop.Excel.Workbooks
    Public XLbook As Microsoft.Office.Interop.Excel.Workbook
    Public XLsheets As Microsoft.Office.Interop.Excel.Sheets
    Public XLworksheet As Microsoft.Office.Interop.Excel.Worksheet
    Public XLrange As Microsoft.Office.Interop.Excel.Range

    'DATA INPUT VARIABLES & VARIABLE ARRAYS
    Public Imax, Imaxo, Ismax, Jmax, Kmax, Kmax_stern, Kmax_bow As Integer
    Public π, Loa, Lbp, Bmld, Dmld, Tdes, rof, Rbs, Rss, SHfwd, SHaft, HFDcl, HPDcl As Double
    Public Bstr_min, cmb, cmbfc, cmbp, MDkBcl, FDkBcl, PDkBcl, LWT, Tlwt, KGo, Rbow As Double
    Public StraightCamber As Boolean

    etc.

    'DESIGN CAD 3D INTERFACE VARIABLES.
    Public DcApp As DesignCAD.Application
    Public DcDocs As DesignCAD.Documents
    Public DcDoc As DesignCAD.Document
    Public DcViews As DesignCAD.Views
    Public DcView As DesignCAD.View
    Public DcMark As DesignCAD.PointMark
    Public DcPts As DesignCAD.CmdPoints
    Public DcLine As DesignCAD.Line
etc.



Entity IDs and .NET Languages 
Pavlos

prl

Quote from: Pavlos on July 25, 2014, 04:47:11 AM
all variables name are declared as Public at Module level, as shown in the following:

Not shown in your example is the DcEnt declaration.  Is it there in the public section you show?

Pavlos

The following is the entire DesignCAD Interface Structure.  With exception of the last five "EDO" type, all the rest have been used in the program.  Because of the problem being encountered, I did not think the any of the last five could be used reliably, if at all.

DESIGN CAD 3D INTERFACE VARIABLES.
    Public DcApp As DesignCAD.Application
    Public DcDocs As DesignCAD.Documents
    Public DcDoc As DesignCAD.Document
    Public DcViews As DesignCAD.Views
    Public DcView As DesignCAD.View
    Public DcMark As DesignCAD.PointMark
    Public DcPts As DesignCAD.CmdPoints
    Public DcLine As DesignCAD.Line
    Public DcLineStyle As DesignCAD.LineStyle
    Public DcArc As DesignCAD.Arc_
    Public DcCurve As DesignCAD.Curve
    Public DcPlane As DesignCAD.Plane
    Public DcSurf As DesignCAD.Surface
    Public DcSelection As DesignCAD.Selection
    Public DcSolid As DesignCAD.Solid
    Public DcTrim As DesignCAD.Trim
    Public DcLayers As DesignCAD.Layers
    Public DcLayer As DesignCAD.Layer

    Public DcEnts As DesignCAD.Entities
    Public DcEnt As DesignCAD.Entity
    Public DcEnt_Point As DesignCAD.Entity
    Public DcEnt_BowPoint() As DesignCAD.Entity
    Public DcEnt_SternPoint() As DesignCAD.Entity

    Public DcEnt_Line As DesignCAD.Entity, DcEnt_Line1 As DesignCAD.Entity
    Public DcEnt_Arc As DesignCAD.Entity
    Public DcEnt_Plane As DesignCAD.Entity, DcEnt_Plane1 As DesignCAD.Entity, DcEnt_Plane2 As DesignCAD.Entity

    Public DcEnt_SternProfile As DesignCAD.Entity
    Public DcEnt_BowProfile As DesignCAD.Entity

    Public DcEnt_BL As DesignCAD.Entity, DcEnt_CL, DcEnt_AP As DesignCAD.Entity, DcEnt_FP As DesignCAD.Entity
    Public DcEnt_MnDkCL As DesignCAD.Entity, DcEnt_MnDkAtS As DesignCAD.Entity

    Public DcEnt_XL As DesignCAD.Entity, DcEnt_YL As DesignCAD.Entity, DcEnt_ZL As DesignCAD.Entity
    Public DcEnt_RL As DesignCAD.Entity, DcEnt_RLx As DesignCAD.Entity
    Public DcEnt_RL1 As DesignCAD.Entity, DcEnt_RL2 As DesignCAD.Entity
    Public DcEnt_Curve As DesignCAD.Entity
    Public DcEnt_BT() As DesignCAD.Entity
    Public DcEnt_WL() As DesignCAD.Entity
    Public DcEnt_WLaftpart() As DesignCAD.Entity
    Public DcEnt_WLfwdpart() As DesignCAD.Entity
    Public DcEnt_TF() As DesignCAD.Entity
    Public DcEnt_SF() As DesignCAD.Entity
    Public DcEnt_WLatH As DesignCAD.Entity
    Public DcEnt_StrFr As DesignCAD.Entity
    Public DcEnt_TransomPlane As DesignCAD.Entity, DcEnt_Transom As DesignCAD.Entity
    Public DcEnt_PoopDeckCL As DesignCAD.Entity, DcEnt_ForecastleDeckCL As DesignCAD.Entity
    Public DcEnt_PoopDeckAtS As DesignCAD.Entity, DcEnt_ForecastleDeckAtS As DesignCAD.Entity
    Public DcEnt_PoopFwdEndCasing As DesignCAD.Entity, DcEnt_ForecastleAftEndCasing As DesignCAD.Entity

    Public DcEntPointEDO As DesignCAD.EntPoint
    Public DcEnt_LineEDO As DesignCAD.EntLine
    Public DcEnt_Line1EDO As DesignCAD.EntLine
    Public DCEntCurveEDO As DesignCAD.EntCurve
    Public DCPlaneEDO As DesignCAD.EntPlane

DcEnt_PoopDeckAtS is in the 7th line from the end.

I really I have to get to the bottom of this instability problem because it showed up in elsewhere in the code.  I will report on any progress made.

Regards
Pavlos



Pavlos

DrollTroll

I'm still suspicious that the problem may be caused by misrepresented entity ids. Please try something like this:

Dim dcEnt as DesignCAD.Entity
Dim rid as Decimal ' id returned by the Draw command
Dim eid as oaCurrency Long 'corrected id

rid = SomeObject.Draw()
eid = Decimal.ToOACurrency(rid)
dcEnt = GetEntityByID(eid)
if dcEnt is Nothing then MessageBox.Show ("Entity returned id " + rid.ToString()  + ", converted to object id " + Convert.ToString(eid) " doesn't seem to exist")
25 years with DesignCAD

DrollTroll

Here's a simple "one-button project" to demonstrate the problem. The program draws 100 lines. It then tries to use GetEntityByID using the original returned entity id, and that same id converted to OACurrency. If both ids were equivalent, it'd get the same object every time, but it fails about 10% of the time. The attached image shows what happens at the tenth entity. It's entity id should be 10 (or as currency value, 0.0010) but when obtained using the Draw command's returned, unconverted ID, GetEntityID returns entity id 1 (currency 0.0001).

Imagine then that you're trying to use GetEntityByID with the wrong, unconverted value in a frequently-edited drawing. If you've been creating and deleting objects during the drawing's lifetime, using the unconverted Draw() return value in GetEntityByID or SelectByID or similar methods may point to an entity that no longer exists, thus giving you a NULL or NOTHING entity. Even if it does successfully retrieve SOME object, there's a chance it could retrieve the WRONG object.

Moral of this story: For DotNet, always convert your returned entity ids to LONG values using Decimal.ToOACurrency, and use these converted values to pass back to your *ByID methods.

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ' This project demonstrates that the value returned by the Draw() functions must be converted
        ' to OACurrency before passing back to DesignCAD via GetEntityByID or SelectByID, or other
        ' methods that require an entity id as an object.


        Dim DcApp As DesignCAD.Application
        Dim DcDocs As DesignCAD.Documents
        Dim DcDoc As DesignCAD.Document
        Dim DcPts As DesignCAD.CmdPoints
        Dim DcCurve As DesignCAD.Curve
        Dim DcEnts As DesignCAD.Entities
        Dim DcEnt1 As DesignCAD.Entity
        Dim DcEnt2 As DesignCAD.Entity
        Dim RID As Decimal 'ID returned from Draw(). DotNet sees DesignCAD's currency values as Decimal instead. So type it explicitly.
        Dim EID As Long ' We will convert the Decimal entity ID to a 64-bit integer Entity ID (essentially the same as Currency)

        On Error Resume Next
        DcApp = GetObject(, "DesignCAD.Application")
        If DcApp Is Nothing Then
            DcApp = New DesignCAD.Application
        End If
        If DcApp Is Nothing Then
            MessageBox.Show("Can't connect to DesignCAD. Exiting...")
            Close()
            Exit Sub
        End If
        DcDocs = DcApp.Documents
        DcDoc = DcDocs.Add
        DcCurve = DcDoc.Curve
        DcPts = DcDoc.CmdPoints
        Dim i As Integer
        For i = 0 To 100
            DcPts.SetCommandPoint(0.0, 5.0 * i, 0.0)
            DcPts.SetCommandPoint(5.0, 5.0 * i + 2.0, 0.0)
            DcPts.SetCommandPoint(10.0, 5.0 * i, 0.0)
            RID = DcCurve.Draw ' seen as a Decimal value by DotNet, not a Currency value
            EID = Decimal.ToOACurrency(RID) ' convert it to an actual Currency value
            DcEnts = DcDoc.Entities
            Err.Clear()
            DcEnt1 = DcEnts.GetEntityByID(EID) 'try getting the entity by the corrected ID
            If Err.Number <> 0 Then
                Me.BringToFront()
                MessageBox.Show("Error 0x" & Hex(Err.Number) & ": " & Err.Description & " while attempting to retrieve entity id " & EID.ToString())
                Err.Clear()
                Continue For
            End If
            DcEnt2 = DcEnts.GetEntityByID(RID) 'try getting the entity by the Decimal ID -- sometimes it's right, sometimes it's wrong
            If Err.Number <> 0 Then
                Me.BringToFront()
                MessageBox.Show("Error 0x" & Hex(Err.Number) & ": " & Err.Description & " while attempting to retrieve entity id " & RID.ToString())
                Err.Clear()
                Continue For
            End If
            If DcEnt1.EntityID <> DcEnt2.EntityID Then
                Me.BringToFront()
                MessageBox.Show("Mismatched entity ids -- EID entity=" & DcEnt1.EntityID.ToString() & ", RID entity=" & DcEnt2.EntityID.ToString())
            End If
        Next
        DcEnt1 = Nothing
        DcEnt2 = Nothing
        DcEnts = Nothing
        DcPts = Nothing
        DcCurve = Nothing
        DcDoc = Nothing
        DcDocs = Nothing
        DcApp = Nothing
        Close()
    End Sub
25 years with DesignCAD

Pavlos

Many thanks for explaining the problem and providing the solution so comprehensively.

Some last things I would like to ask are the following:

Would there be any objection in using the following shortcut form in a large program.

DcEnt1 = DcEnts.GetEntityByID(Decimal.ToOACurrency(DcCurve.Draw))

As I have confirmed, everywhere in my program, code of the form:
"Icount = DcEnt1.PointsCount", "Pointsretrieved = DcEnt1.GetPoints(1, Icount, XYZarray)", or simply DcEnt1.Delete, follow immediately or shortly after.


On another subject entirely, in the earlier VB6 version of the program I am currently working on, most of the action occurred in the Form, while the module was simply the place where all the variables were declared as Public.  In the form therefore I had the following events.

Private Sub Form_Initialize()
    Set DcApp = Nothing
    Set DcDocs = Nothing
    Set DcDoc = Nothing
    Set DcViews = Nothing
    Set DcView = Nothing
    Set DcMark = Nothing
    Set DcPts = Nothing
    Set DcLine = Nothing
    Set DcLineStyle = Nothing
    Set DcCurve = Nothing
    Set DcPlane = Nothing
    Set DcSurf = Nothing
    Set DcSelect = Nothing
    Set DcSolid = Nothing
    Set DcTrim = Nothing
    Set DcEnts = Nothing
    Set XLbook1 = Nothing
    Set XLworksheet1 = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim III As Integer
        For III = Forms.Count - 1 To 1 Step -1
            Unload Forms(III)
        Next III
    If Me.WindowState <> vbMinimized Then
        SaveSetting App.Title, "Settings", "MainLeft", Me.Left
        SaveSetting App.Title, "Settings", "MainTop", Me.Top
        SaveSetting App.Title, "Settings", "MainWidth", Me.Width
        SaveSetting App.Title, "Settings", "MainHeight", Me.Height
    End If
            DcDoc.ActiveView.Application.Quit
            Set DcApp = Nothing
            Set DcDocs = Nothing
            Set DcDoc = Nothing
            Set DcViews = Nothing
            Set DcView = Nothing
            Set DcMark = Nothing
            Set DcPts = Nothing
            Set DcLine = Nothing
            Set DcLineStyle = Nothing
            Set DcCurve = Nothing
            Set DcPlane = Nothing
            Set DcSurf = Nothing
            Set DcSelect = Nothing
            Set DcSolid = Nothing
            Set DcTrim = Nothing
            Set DcEnts = Nothing
            Set XLbook1 = Nothing
            Set XLworksheet1 = Nothing
End Sub

In the current VB 2010 version of the program, as one of the options being considered was to eventually create a User Defined tool bar that would load onto DesignCAD 23, and make it entirely user friendly to any Naval Architect, without sacrificing any of the great attributes of DesignCAD itself,  I have placed 95% of all the code including all the variables declaration in a module.  The one form in the project, is simply a collection of buttons that are self explanatory by their title and tooltip text, to any Naval Architect, however early in his training he may happen to be, and at this stage, I only have a single, multipurpose Dialog form, that automatically adjusts itself, in accordance to the procedure from which it is being called.

In your last posting I have noticed that you coded at the end of the procedure
        DcEnt1 = Nothing
        DcEnt2 = Nothing
        DcEnts = Nothing
        DcPts = Nothing
        DcCurve = Nothing
        DcDoc = Nothing
        DcDocs = Nothing
        DcApp = Nothing
        Close()

As I said in my earlier posting, I am not a professional programmer, but merely a committed user who has resorted to programming, due to the fact that the software available out there, simply fails to address my Naval Architecture needs the way I see them.  The question I have therefore is the following:
Are any programming principles being compromised if I simply let VB 2010 do the final house cleaning for me, when I exit the program by pressing the "EXIT" button on the form ?

Best Regards
Pavlos


Pavlos