News:

The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software can be used with TurboCAD.

Main Menu

Tools

Started by AlanWard2022, February 13, 2024, 05:54:33 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

AlanWard2022

I am trying to perform a BOOLEAN 3D Subtraction with solid objects I have created programmatically and they are still in memory as R and RR. The only way I think it can be done is by activating the tool.
I know the tool name and I have looked at the tool properties and the only method associated with it is activate(). It is the syntax / language I am struggling with.

I guess the method syntax would be the same for all tools.
Any help would be much appreciated.

nikkipollard

#1
I am guessing you want to do this with code.
What programming language?

this is what I do with VB.net

Reference this file
gxext24.dll
C:\Program Files\IMSIDesign\TCWP2017\Program64\ImsigxExt\gxext24.dll

Dim TCBoolSrv As GXEXTLib.Boolean3D
            TCBoolSrv = TCapp.CreateObject("GXEXT.Boolean3D")

            Dim Badd1 As IMSIGX.Graphic
            Dim Badd2 As IMSIGX.Graphic
                 Badd1 = Tcdraw.Graphics.Add(, "TCW40CUBE")
                Badd1.Vertices.Add(-100, -100, 0)
                Badd1.Vertices.Add(-100, 100, 0)
                Badd1.Vertices.Add(100, -100, 0)
                Badd1.Vertices.Add(-100, -100, 1000)
               Badd1.Draw

            Badd2 = Badd1.Duplicate
          Badd2.RotateAxis(Radians(45), 0, 0, 1, 0, 0, 0)
           Badd2.Draw()
          Dim BooAdd As IMSIGX.Graphic
          BooAdd = TCBoolSrv.Add(Badd1, Badd2)
        Badd1.Delete()
        Badd2.Delete()
        TCDraw.Graphics.AddGraphic(BooAdd)
        BooAdd.Draw()



Dim prof1, prof2, gsub As IMSIGX.Graphic
        prof1 = TCdraw.Graphics.AddLinePolygon(0, 0, 0, 0, 100, 0, 6)        'adds hexagon
        Dim HGHT As Double
        HGHT = 1000
        Dim Extrde As IMSIGX.Graphic
        Extrde = TCdraw.Graphics.Add(, "TCW120SIMPLEEXTRUDE")
        Extrde.Properties.Item("Solid").Value = 1
        Extrde.Vertices.UseWorldCS = True
        TCdraw.Graphics.Remove(prof1.Index)
        Extrde.Graphics.AddGraphic(prof1)
        Extrde.Properties.Item("$SWEEPDIST").Value = HGHT
        Extrde.Update()
        Extrde.Draw()
        prof2 = TCdraw.Graphics.AddCircleCenterAndPoint(0, 0, 0, 20, 0, 0)
        gsub = TCdraw.Graphics.Add(, "TCW120SIMPLEEXTRUDE")
        gsub.Properties.Item("Solid").Value = 1
        gsub.Vertices.UseWorldCS = True
        TCdraw.Graphics.Remove(prof2.Index)
        gsub.Graphics.AddGraphic(prof2)
        gsub.Properties.Item("$SWEEPDIST").Value = HGHT
        gsub.Update()
        gsub.Draw()

        Dim TCBoolSrv As GXEXTLib.Boolean3D
        TCBoolSrv = TCapp.CreateObject("GXEXT.Boolean3D")
        Dim BooSubtract As IMSIGX.Graphic
        BooSubtract = TCBoolSrv.Subtract(Extrde, gsub)
        Extrde.Delete()
        gsub.Delete()
        TCdraw.Graphics.AddGraphic(BooSubtract)
        BooSubtract.Draw()
        TCdraw.ActiveView.Refresh()



        Dim gf1, prof1, gf2 As IMSIGX.Graphic
        prof1 = TCdraw.Graphics.AddLineRectangle(-100, -100, 0, 100, 100, 0)
        gf1 = TCdraw.Graphics.Add(, "TCW120SIMPLEEXTRUDE")
        gf1.Properties.Item("Solid").Value = 1
        gf1.Vertices.UseWorldCS = True
        TCdraw.Graphics.Remove(prof1.Index)
        gf1.Graphics.AddGraphic(prof1)
        gf1.Properties.Item("$SWEEPDIST").Value = 200
        gf1.Update()
        gf1.Draw()
        gf2 = gf1.Duplicate
        gf2.RotateAxis(Radians(45), 0, 0, 1, 0, 0, 0)
        Dim TCBoolSrv As GXEXTLib.Boolean3D
        TCBoolSrv = TCapp.CreateObject("GXEXT.Boolean3D")
        Dim BooIntersect As IMSIGX.Graphic
        BooIntersect = TCBoolSrv.Intersection(gf1, gf2)
        gf1.Delete()
        gf2.Delete()
        TCdraw.Graphics.AddGraphic(BooIntersect)
        BooIntersect.Draw()
        TCdraw.ActiveView.Refresh()


Above shows 3 different examples of boolean operations.





Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

This was added to the forum years ago and deleted by admin.
This is for vb script.
' MultiAdd.vbs
' VB Script to add multiple 3D solids together
' Thanks to Winston Mitchell for his original VBA code that served as a starting point.
' Version 1.001 -- corrected some cases where non-solids weren't handled correctly
' and cleared the selection when done.
'
' Version 1.002 -- removed some improper Graphic deletions.
' It is a BAD IDEA to use
'     UndoRecord.DeleteGraphic SomeGraphic'
' followed by
'     SomeGraphic.Delete
' This may cause TurboCAD to crash under some circumstances.
'
option explicit

Sub Main
  Dim TCApp
  Dim TCDraw
  Dim TCSel
  Dim TCBoolSrv
 
  On Error Resume Next
  Set TCApp = GetObject("", "TurboCAD.Application")
  If Err.Number <> 0 Then
    MsgBox ("Can't locate TurboCAD. Exiting.")
    Exit Sub
  End If
  TcApp.Visible = True
 
  Set TCDraw = TCApp.ActiveDrawing
  If Err.Number <> 0 Then
    MsgBox ("No active drawing. Nothing to do. Exiting.")
    Exit Sub
  End If
 
  Set TCSel = TCDraw.Selection
  Dim Grf
  Dim i
  Dim RegMethod
  Dim IsMText
  Dim IsSolid
  For i = TCSel.Count - 1 to 0 Step -1
    IsSolid = 0
    Set Grf = TCSel.Item(i)
    IsSolid = Grf.Properties.Item("Solid") ' set to 1 for any object with "Solid" set to 1
    If Err.Number <> 0 Then
      'MsgBox "No Solid property"
      IsSolid = 0
      Err.Clear
    End If
    If Grf.TypeByValue = 6 Then
      'MsgBox "Text entity"
      IsSolid = 0
    End If   
    RegMethod = Grf.Properties.Item("RegenMethod")
    If Err.Number <> 0 Then
      IsSolid = 0
    End If 
    If StrComp(RegMethod, "TCMultiText") = 0 Then
      'MsgBox "MultiText entity"
      IsSolid = 0
    End If
    If IsSolid = 0 Then
      'MsgBox "Not a solid"
      Grf.UnSelect
    End If
    Set Grf = Nothing
  Next
 
  If TCSel.Count < 2 Then
    MsgBox ("Less than 2 solids selected. Select two or more solids and try again.")
    Exit Sub
  End If
  Err.Clear
 
  'Instantiate the 3D Boolean server object
  Set TCBoolSrv = TCApp.CreateObject("GXEXT.Boolean3D")
  If Err.Number <> 0 Then
    MsgBox ("Unable to start Boolean server. Error " & Hex(Err.Number) & ": " & Err.Description)
    Exit Sub
  End If
 
  Dim MultiAddUndo ' Undo record for the MultiAdd operation'
  Set MultiAddUndo = TCDraw.AddUndoRecord("MultiAdd")
 
  Dim TCBoolAdd1 'Working boolean result
  Dim TCBoolAdd2 'Temporary boolean result
 
  i = TCSel.Count - 1 'Item indices start at 0
  Set TCBoolAdd1 = TCBoolSrv.Add(TCSel.Item(i), TCSel.Item(i - 1)) ' Add the first two primitives to create a new graphic
  MultiAddUndo.DeleteGraphic(TCSel.Item(i))   ' Remove the pre-boolean primitives as they are used
  MultiAddUndo.DeleteGraphic(TCSel.Item(i-1))
  For i = TCSel.Count - 1 to 0 Step -1
    Set TCBoolAdd2 = TCBoolSrv.Add(TCSel.Item(i), TCBoolAdd1) 'Add each remaining primitive to the current Boolean graphic
    Set TCBoolAdd1 = TCBoolAdd2 ' Update the working result from the temporary result
    MultiAddUndo.DeleteGraphic(TCSel.Item(i)) ' and remove the primitive
  Next
  TCDraw.Graphics.AddGraphic(TCBoolAdd1) ' Add the final boolean graphic to the drawing's Graphics collection'
  MultiAddUndo.AddGraphic(TCBoolAdd1) ' Add the new graphic to the Undo record'
  MultiAddUndo.Close  ' All done. Close the Undo record'
  TCDraw.UnselectAll ' Clear the selection
  TCDraw.ActiveView.Refresh 'Refresh the view
  Set TCBoolAdd2 = Nothing
  Set TCBoolAdd1 = Nothing
  Set TCSel = Nothing
  Set TCDraw = Nothing
  Set TCApp = Nothing
End Sub

Main

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Thank you very much for your help.

Can you tell me though why I can't get any tools to 'activate()'

Knowing this would help me very much in the future I am sure.

nikkipollard

#4


I don't know. It is one of the things I tried, when I first started experimenting with the SDK.
 It is something the macro recorder does when you record with the mouse click on, but it only works for recorded macros.
The SDK has a method for most of the older tools we use in Turbocad.
This might be pretty obvious to you but, not being a programmer this is what I had to wrap head around in the beginning.

Say I want to add a loft, between a rectangle and a circle
I draw the rectangle using

grec = drawing.Graphics.AddlineRectangle(x1,y1,z1,x2,y2,z2)
 (or whatever the syntax of the program you are using is)

where drawing is the active drawing
Graphics is the list of Graphics in the drawing
add line rectangle is the method to draw a rectangle.

similarly draw the circle - there are quite a few circle functions , I like this one

gcirc = drawing.Graphics.AddCircleCenterAndPoint(centre x, centre y, centre z,radius+centre x, centre y, centre z)

A circle is a graphic a graphic object has a list of methods.
Move the circle in the Z direction using

gcirc.MoveRelative(distance x,distance y,distance z)
a loft is also a graphic, it needs to be added to a list of graphics.

gloft = drawing.Graphics.Addloft(grec,gcirc)

A Graphic can have a list of Graphics - which define it.
The loft has the circle and the rectangle.
You can add more 2d profiles to the loft using
g = gloft.Graphics.Add-()

Where the dash is whichever method you choose

To change the layer of a graphic
gloft.Layer = "Lofts"
Note: Use the name of the layer, the method expects text Layer 0 needs to be "0"

Other Graphic properties - such as the ones found in the Selection Info Palette - can be changed using

gloft.Properties.Item("PenColor").Value = 255 - Use the macro recorder to find out the name of the property - Property names are case sensitive.






Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

#5
C:\Program Files\IMSIDesign\TCW2021\SDK\Docs

This is where to find the help documents for the SDK on your computer - obviously depending on your version.
All the methods and a vague idea on the syntax for VBA and C++ are there.

This file was also shared on the forum but was deleted by admin - there was something we needed to do to be able to see it.
If I can find the thread I will link to it.
Unfortunately all the documents are VBcentric, and the internet palette no longer exists in TC.

https://forums.turbocad.com/index.php?topic=2960.0

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi,

I haven't had much luck with the Boolean3D Subtract / Add

The only difference between my application syntax and your VB.Net is you define the variable type as IMSIGX.Graphic and I don't define it, just give it its value then

TCBoolSrv = CAD.CreateObject("GXEXT.Boolean3D")
BooSubtract = TCBoolSrv.Subtract(b, a)

So I have ventured into the world of Visual Studio 2022 VB.Net




Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim prop
        V.a = V.GR.addlinerectangle(0, 0, 0, 100, 100, 0)
        prop = V.a.Properties.Item("PenColor")
        prop.Value = 0
        prop = V.a.Properties.Item("Thickness")
        prop.Value = 150
        prop = V.a.Properties.Item("Solid")
        prop.Value = 1
        V.a.draw()

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim prop
        V.b = V.GR.addlinerectangle(0, 0, 0, 50, 50, 0)
        prop = V.b.Properties.Item("PenColor")
        prop.Value = 255
        prop = V.b.Properties.Item("Thickness")
        prop.Value = 150
        prop = V.b.Properties.Item("Solid")
        prop.Value = 1
        V.b.draw()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


        Dim TCBoolSrv As GXEXTLib.Boolean3D
        TCBoolSrv = V.CAD.CreateObject("GXEXT.Boolean3D")
        Dim BooSubtract As IMSIGX.Graphic
        BooSubtract = TCBoolSrv.Subtract(V.a, V.b)
        V.a.Delete()
        V.b.Delete()
        V.GR.Graphics.AddGraphic(BooSubtract)
        BooSubtract.Draw()
        V.GR.ActiveView.Refresh()

    End Sub
End Class


Public Class V
    Public Shared CAD = CreateObject("Turbocad.Application.4")
    Public Shared GR = CAD.Activedrawing.graphics
    Public Shared a
    Public Shared b
End Class

This is a three buttoned form. One to draw a large cube, one to draw a smaller cube and the third to subtract one from the other.

I have Added a reference to GXEXT30.dll and I can see in the object browser that it contains the Boolean 3D Class etc.

When I run the above code it immediately gives an error " Type 'IMSIGX.Graphic' is not defined "

As you can see I haven't included the As IMSIGX.Graphic when calling the public variables a and b but buttons 1 & 2 do work and draw the objects correctly.

When I remove the text As IMSIGX.Graphic I get a different error and only on pressing button 3 to activate the subtraction:

System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

I guess this is the same problem I have been getting on DBase which is what I was using before for programming so I can see the As IMSIGX.Graphic is essential.

Do you know what I may be doing wrong ?

I think the error "Type 'IMSIGX.Graphic' is not defined" needs to be addressed and then the code would probably work.


nikkipollard

#7
Hi
It looks like you haven't  referenced the main Turbocad Library. either Imsigx30.dll or Imsimgx.dll found here
C:\Program Files\IMSIDesign\TCW2021\Program64.

If you look at the help document. IMSIGXReference.chm
Go to the contents page
On the right is list of the libraries that can be referenced for Turbocad.
If You click on the plus sign next to each one you can see what you can do with that library.
- A list of objects under each library - or classes depending on which reference you used. - I don't really understand.
If you click on those object names you can see the methods and properties available to each object.

The Graphics and Graphic Classes are in the IMSIGX namespace.
The Boolean Operations are available in the Extension - which you referenced.
Be aware that windows forms use a Graphic class too. So if you are going to use VB.net or C# there might be a conflict if you refer to an IMSIGX.Graphic as a Graphic.



Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

#8
I know PHP doesn't specify variable types -  plays the guessing game like Ruby and vbscript.
But out of curiosity, when you tried VB.net, did you try dimensioning variables the long winded way - like my example? I found it quite helpful when I initially explored the SDK.
I appreciate the assistance from the IDE as soon as I type the dot or parenthesis.
You can see the difference in the screen shot.
I have attached an example solution.


Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi,

Being new to VB.Net I copied your syntax exactly.

I still can't get the boolean operation to work though. I have downloaded your example. When I tried to run it for the first time I had to download the Net 6.0 to my Visual Studio as I was using Net 8.0

Your example returns me the same error :

System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

Any ideas please ?

nikkipollard

Did you try googling the error?
It sounds like an old/new version error. I have similar errors with the example files in the SDK.
Try reloading the references in my file to match yours.
Or start a new project and copy the code line by line testing it as you go.
Very painful, I hope they haven't broken the SDK with the new version.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi,

There is no difference if I use the dll files in your example I downloaded or the ones with my Turbocad (Platinum 2023)

I have tried renaming, relocating them but still no good.

One thing I have noticed though in visual studio in the properties the GXEXTLib description is :

GXExt 8.0 Type Library, IMSIGX extension.

whereas the IMSIGX description is

TurboCAD v4.1 Programmable Objects.

Both say file type is Activex

I don't know if this is relevant.


nikkipollard

#12
I am not a programmer
I don't know why visual studio works for me and not you.
Ted had a similar problem maybe this will help.
https://forums.turbocad.com/index.php?topic=30729.0

Maybe it is the way I add the reference that is different to you.
Right, click on Dependencies, Add project reference and Browse for the files.

The only other thing I can think of is our different versions of Turbocad.
If this doesn't work in the macro recorder - then maybe the SDK is broken in the newer versions copy and paste the code into the macro recorder palette and
to test.
Option Explicit

Dim TCBoolSrv
          Set  TCBoolSrv = CreateObject("GXEXT.Boolean3D")

            Dim Badd1
            Dim Badd2
                 Set Badd1 = ActiveDrawing.Graphics.Add(, "TCW40CUBE")
                Badd1.Vertices.Add -100, -100, 0
                Badd1.Vertices.Add -100, 100, 0
                Badd1.Vertices.Add 100, -100, 0
                Badd1.Vertices.Add -100, -100, 1000
               Badd1.Draw

          Set  Badd2 = Badd1.Duplicate
          Badd2.RotateAxis 0.785398163397448, 0, 0, 1, 0, 0, 0
           Badd2.Draw
          Dim BooAdd
         Set  BooAdd = TCBoolSrv.Add(Badd1, Badd2)
        Badd1.Delete
        Badd2.Delete
        ActiveDrawing.Graphics.AddGraphic(BooAdd)
        BooAdd.Draw

 
ActiveDrawing.ActiveView.Refresh

Set Badd1 = Nothing
Set Badd2 = Nothing
Set BooAdd = Nothing






Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Quote from: nikkipollard on April 02, 2024, 09:23:24 PMThe only other thing I can think of is our different versions of Turbocad.

If this doesn't work in the macro recorder - then maybe the SDK is broken in the newer versions copy and paste the code into the macro recorder palette and to test.

Hi Nikki.   Your VB example file worked fine for me using TC 2022, VS 2022 and Net 4.8. (I opened TC with a blank file before running the example in Visual studio).   but your Macro doesn't work for me in 2022, nor 2021.  It draws the boxes but not the Boolean added object.

nikkipollard

Quote from: Andy H on April 03, 2024, 03:23:34 AM
Quote from: nikkipollard on April 02, 2024, 09:23:24 PMThe only other thing I can think of is our different versions of Turbocad.

If this doesn't work in the macro recorder - then maybe the SDK is broken in the newer versions copy and paste the code into the macro recorder palette and to test.

Hi Nikki.   Your VB example file worked fine for me using TC 2022, VS 2022 and Net 4.8. (I opened TC with a blank file before running the example in Visual studio).   but your Macro doesn't work for me in 2022, nor 2021.  It draws the boxes but not the Boolean added object.
Quote from: Andy H on April 03, 2024, 03:23:34 AM
Quote from: nikkipollard on April 02, 2024, 09:23:24 PMThe only other thing I can think of is our different versions of Turbocad.

If this doesn't work in the macro recorder - then maybe the SDK is broken in the newer versions copy and paste the code into the macro recorder palette and to test.

Hi Nikki.   Your VB example file worked fine for me using TC 2022, VS 2022 and Net 4.8. (I opened TC with a blank file before running the example in Visual studio).   but your Macro doesn't work for me in 2022, nor 2021.  It draws the boxes but not the Boolean added object.

The macro works on my version of 2021.
Does it throw an error?
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Quote from: nikkipollard on April 03, 2024, 06:42:19 AMThe macro works on my version of 2021.
Does it throw an error?

No error.  The macro finishes processing OK, but just leaves the two boxes in the drawing, nothing Boolean added.  I'll have a play with it later.  Maybe something in my TC setup is interfering with it.

nikkipollard

#16
Quote from: Andy H on April 03, 2024, 08:01:59 AM
Quote from: nikkipollard on April 03, 2024, 06:42:19 AMThe macro works on my version of 2021.
Does it throw an error?

No error.  The macro finishes processing OK, but just leaves the two boxes in the drawing, nothing Boolean added.  I'll have a play with it later.  Maybe something in my TC setup is interfering with it.
It is strange that the boxes are still there, because I deleted them after I added the final graphic to the drawing.

It is so frustrating that it is not consistent. Methods that work with Imsigx28.dll don't work in IMSImgx.dll or the .tlb versions.
I am hoping that with the introduction of AI into Turbocad, that they also took the time to fix the SDK.
Silly things like the AddLinePolygon function not working in IMSIGX.tlb but working fine in the dll version is just annoying.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi Nikki,

Your Macro doesn't work in my Platinum 2023 either, and the two boxes are still there as well. No errors.

If I remove everything from the macro regarding the Boolean Add it creates and deletes the boxes as it should.

When I perform the  CreateObject("GXEXT.Boolean3D") in my DBase programming software and in Visual Studio it does create the object as I can inspect the object and see the methods. It is the methods that are not working. The same applies when I use your dll's from the example you added.

If it is a version thing then it must be Turbocad 2023 that is different somehow.


nikkipollard

That is very annoying.
I tested the .tlb files and had so many crashes as you described.
Do Parametric symbols still work in 2023?
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi Nikki,

I don't know as I have never used them, or know what they are to be honest.

John R

Quote from: nikkipollard on April 04, 2024, 06:37:50 AMThat is very annoying.
I tested the .tlb files and had so many crashes as you described.
Do Parametric symbols still work in 2023?
I believe so.

John R.

V17—V21, 2015—2025
Designer, Deluxe, (Basic, Expert, Professional), Platinum
RedSDK enabled
Windows 11 Pro (25H2), 64-bit

Andy H

#21
Quote from: nikkipollard on April 03, 2024, 08:03:21 PMIt is so frustrating that it is not consistent. Methods that work with Imsigx28.dll don't work in IMSImgx.dll or the .tlb versions.

I Finally got round to having a look for the problem I encountered,  and after a bit of research into AnimationLab, it needed just one change.  I changed the line -  Set TCBoolSrv = CreateObject("GXEXT.Boolean3D"), to.

Set  TCBoolSrv = ActiveDrawing.Application.CreateObject("GxExt.Boolean3D")

The Macro then worked as expected.

The AniationLab Script is s follows
       tcVer = getTCMajorVersion()
      if (CInt(tcVer)) > 9 then
         Set BooleanEngine = ActiveDrawing.Application.CreateObject("GxExt.Boolean3D")
      else
         Set BooleanEngine = CreateObject("GxExt.Boolean3D")
      end if

So it looks like the SDK was changed from v10 onwards.   I haven't a clue how the shorter syntax is working OK on your system, but not on Mine nor Alans.

nikkipollard

#22
Ok that makes sense.
Sort of.
Does your solution work in the 2022 version?

I suspect the macro works for me because I only have one version of TC on this computer so it is automatically choosing the correct .dll files. (The 28 version which still works.)  Your Syntax works because it is telling it to use the same application as the drawing file - 2021
but if your syntax works in the TC2022 version - then I am wrong - I hope I am wrong.
I guess you could test my theory by Testing to see if msgbox(Application) and msgbox(ActiveDrawing.Application) are the same.


Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Quote from: nikkipollard on April 04, 2024, 09:10:53 PMOk that makes sense.
Sort of.
Does your solution work in the 2022 version?

Just tried it, Yes it works in v2022. Though I guess the real test is whether Alan can make it work in 2023. 

It wasn't really my solution,  The AnimationLab (AL) script was written by the programmers.  But as I knew it worked in AL, I just looked for the difference between that and the Macro.   

I suspect it only affects GxExt.Boolean3D, I have used Create Object before, but to create application (Set appl = CreateObject("TurboCAD.Application"). And that worked without needing the Active drawing bit.

nikkipollard

Quote from: Andy H on April 04, 2024, 11:40:13 PM
Quote from: nikkipollard on April 04, 2024, 09:10:53 PMOk that makes sense.
Sort of.
Does your solution work in the 2022 version?

Just tried it, Yes it works in v2022. Though I guess the real test is whether Alan can make it work in 2023. 

It wasn't really my solution,  The AnimationLab (AL) script was written by the programmers.  But as I knew it worked in AL, I just looked for the difference between that and the Macro.   

I suspect it only affects GxExt.Boolean3D, I have used Create Object before, but to create application (Set appl = CreateObject("TurboCAD.Application"). And that worked without needing the Active drawing bit.
I think you might be onto something. I was testing the .tlb libraries. - TC kept crashing, with the fillet and shell commands. I changed the code to your code, and touch wood, It hasn't crashed. Possibly using a different application object with functions that still work.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi Nikki, Hi Andy,

Unfortunately it doesn't work. I have tried the macro way and changing my code.

Dim CAD As IMSIGX.Application = CreateObject("Turbocad.Application.4")
Dim a As IMSIGX.Graphic
Dim b As IMSIGX.Graphic
Dim c As IMSIGX.Graphic
Dim TT As GXEXTLib.Boolean3D
Dim prop As IMSIGX.Property

a = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 50, 50, 0)
prop = a.Properties.Item("PenColor")
prop.Value = 0
prop = a.Properties.Item("Thickness")
prop.Value = 150
prop = a.Properties.Item("Solid")
prop.Value = 1
a.Draw()

b = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 20, 20, 0)
prop = b.Properties.Item("PenColor")
prop.Value = 255
prop = b.Properties.Item("Thickness")
prop.Value = 200
prop = b.Properties.Item("Solid")
prop.Value = 1
b.Draw()

TT = CAD.ActiveDrawing.Application.CreateObject("GXEXT.Boolean3D")
c = TT.Subtract(a, b)
a.Delete()
b.Delete()
c.Draw()


Both objects are drawn and then the error occurs at c = TT.Subtract(a, b)

I can jump onto Turbocad and perform the subtraction or addition so I know the objects themselves are ok.

I really do appreciate both of you helping. I will keep on battling on.

Thanks.

Andy H

#26
Quote from: Alan Ward on April 05, 2024, 04:01:23 AMBoth objects are drawn and then the error occurs at c = TT.Subtract(a, b)

A minor alteration to the code (see items in blue). c.draw() not needed.  Tested with TC 2022 open with a new blank drawing, and Visual studio 2022.

Please See Nikki's example Visual studio file for any setup Code.

Dim CAD As IMSIGX.Application = CreateObject("Turbocad.Application.4")
Dim a As IMSIGX.Graphic
Dim b As IMSIGX.Graphic
Dim c As IMSIGX.Graphic
Dim TT As GXEXTLib.Boolean3D
Dim prop As IMSIGX.Property
Dim drwg As IMSIGX.Drawing

a = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 50, 50, 0)
prop = a.Properties.Item("PenColor")
prop.Value = 0
prop = a.Properties.Item("Thickness")
prop.Value = 150
prop = a.Properties.Item("Solid")
prop.Value = 1
a.Draw()

b = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 20, 20, 0)
prop = b.Properties.Item("PenColor")
prop.Value = 255
prop = b.Properties.Item("Thickness")
prop.Value = 200
prop = b.Properties.Item("Solid")
prop.Value = 1
b.Draw()

drwg = CAD.ActiveDrawing
TT = CAD.ActiveDrawing.Application.CreateObject("GXEXT.Boolean3D")
c = TT.Subtract(a, b)
drwg.Graphics.AddGraphic(c)
a.Delete()
b.Delete()
c.Draw()

drwg.ActiveView.Refresh()

nikkipollard

#27
Quote from: Andy H on April 05, 2024, 10:20:50 AM
Quote from: Alan Ward on April 05, 2024, 04:01:23 AMBoth objects are drawn and then the error occurs at c = TT.Subtract(a, b)

A minor alteration to the code (see items in blue). c.draw() not needed.  Tested with TC 2022 open with a new blank drawing, and Visual studio 2022.

Please See Nikki's example Visual studio file for any setup Code.

Dim CAD As IMSIGX.Application = CreateObject("Turbocad.Application.4")
Dim a As IMSIGX.Graphic
Dim b As IMSIGX.Graphic
Dim c As IMSIGX.Graphic
Dim TT As GXEXTLib.Boolean3D
Dim prop As IMSIGX.Property
Dim drwg As IMSIGX.Drawing

a = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 50, 50, 0)
prop = a.Properties.Item("PenColor")
prop.Value = 0
prop = a.Properties.Item("Thickness")
prop.Value = 150
prop = a.Properties.Item("Solid")
prop.Value = 1
a.Draw()

b = CAD.ActiveDrawing.Graphics.AddLineRectangle(0, 0, 0, 20, 20, 0)
prop = b.Properties.Item("PenColor")
prop.Value = 255
prop = b.Properties.Item("Thickness")
prop.Value = 200
prop = b.Properties.Item("Solid")
prop.Value = 1
b.Draw()

drwg = CAD.ActiveDrawing
TT = CAD.ActiveDrawing.Application.CreateObject("GXEXT.Boolean3D")
c = TT.Subtract(a, b)
drwg.Graphics.AddGraphic(c)
a.Delete()
b.Delete()
c.Draw()

drwg.ActiveView.Refresh()

If you do it this way. You don't need to Dim the application and active drawing globally - like I did.
But you would probably need to use the error handling.
I use it for  bigger projects with lots of sub routines and methods  - it is probably lazy and not the right way to do it. 
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

#28
Bear with me I am not a programmer so I might be asking stupid questions. I am trying to find the problem.
This is my Syntax (from Kevin Chapmans examples)
 
Dim TCApp as IMSIGX.Application
TCApp = GetObject("", "TurboCAD.Application")

This is yours

Dim CAD As IMSIGX.Application = CreateObject("Turbocad.Application.4")

What is the 4 for?
Is that the version?

I think you are going to have to ask for help from support.
I don't think the SDK has been changed since 2014 even though Turbocad has had a major overhaul.
The documentation hasn't been modified.
I am giving you advice on what worked with the 2017 version - When  I test now (with 2021) a lot of methods no longer work. 
However the scripts that were created in 2017, still work in the 2021 version.
If you have an older version you could try using the older reference files.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Quote from: nikkipollard on April 05, 2024, 09:13:33 PMIf you do it this way. You don't need to Dim the application and active drawing globally - like I did.
But you would probably need to use the error handling.
I use it for  bigger projects with lots of sub routines and methods  - it is probably lazy and not the right way to do it. 

Agreed Nikki,  I think its always best to add some error handling,  even for small projects. 

I know you question above was meant for Alan.  But I think your use of GetObject application. is a better fit in this case than CreateObject.   

###########

Alan.  I should point out,  Most of the time, I haven't a clue what I'm doing.  These days, I just write small VBS scripts for TC's AnimationLab plug-in.  I haven't done any proper VB/VBA stuff in fifteen years.  This coupled with a failing memory, means any comments I make,  should be viewed as 'what ever works', rather than good guidance or best practice.   

Alan Ward

Hi both,

I tried your alterations but get the same result.
I don't have a problem with drawing objects at all and applying properties, it is just the boolean that I am finding difficult. I tried the references included in Nikki's example as well as those shipped with Platinum 2023.

As the macro didn't work and it didn't work in my more familiar programming environment Dbase, I am inclined to think it is Turbocad 2023 itself.

I will try technical support and come back to you both.

Thanks again.

nikkipollard

Quote from: Alan Ward on April 06, 2024, 02:48:07 AMHi both,

I tried your alterations but get the same result.
I don't have a problem with drawing objects at all and applying properties, it is just the boolean that I am finding difficult. I tried the references included in Nikki's example as well as those shipped with Platinum 2023.

As the macro didn't work and it didn't work in my more familiar programming environment Dbase, I am inclined to think it is Turbocad 2023 itself.

I will try technical support and come back to you both.

Thanks again.
Vlad is quite active on the forum lately. He is probably the best person to ask - hopefully it is just a case of pointing you to the correct library to use for 2023.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

Quote from: Alan Ward on April 06, 2024, 02:48:07 AMHi both,

I tried your alterations but get the same result.
I don't have a problem with drawing objects at all and applying properties, it is just the boolean that I am finding difficult. I tried the references included in Nikki's example as well as those shipped with Platinum 2023.

As the macro didn't work and it didn't work in my more familiar programming environment Dbase, I am inclined to think it is Turbocad 2023 itself.

I will try technical support and come back to you both.

Thanks again.
How did you get the references included in my example? I was under the impression it just pointed to a file on the computer.

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Hi Nikki, Andy,

They were both in your ExampleBooleanOperations\obj\Debug\Net6.0-windows folder.

Anyway, the good news.

I have just spent a couple of hours un-installing and removing any trace of turbocad and IMSI from my Windows system registry. I then re-installed Turbocad and hey presto. It works. You don't know how happy I am and I'm sorry you both spent all this time and effort helping me when it was a dodgy installation.

I had upgraded from various Deluxe editions to Platinum 2023 so I could draw 3D solids and save them as STEP or IGS files. In all 4 or 5 upgrades since I have had this PC. I wonder if a Deluxe Windows system registry entry was the culprit.

I hope I can re-pay the favour someday.

Best Wishes.

nikkipollard

Hi Alan don't apologise. I am so happy to hear it all works now.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Alan Ward

Thank you Nikki. The function works on my old Dbase as well but I think I will join the 21st Century and stick to VB.Net now.