Author Topic: Tool Palettes/Dockable Containers in AutoCAD  (Read 2733 times)

0 Members and 1 Guest are viewing this topic.

ChuckHardin

  • Guest
Tool Palettes/Dockable Containers in AutoCAD
« on: January 04, 2012, 01:15:15 PM »
I have AutoCAD 2004 and am rewriting old VB6 code to VB.net.

I see a lot about the tool palettes but not much on the AutoCAD Dockable Container.
What are my options with 2004? What versions support ToolPalettes?
Sorry haven't done anything with .net and AutoCAD. Just now switching stuff over as needed.  :cry:

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #1 on: January 04, 2012, 01:27:38 PM »
Are you sure AutoCAD 2004 supports .NET ?
I thaught it was only since 2005 (or 2006).
Speaking English as a French Frog

ChuckHardin

  • Guest
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #2 on: January 04, 2012, 03:25:23 PM »
Add the AutoCAD 2004 Lib. and it works fine.

Here is all I did to make sure I could connect:
Code: [Select]
Imports AutoCAD
Public Class Form1
    '********************************************'
    '*********Varibles for AutoCAD**********'
    '********************************************'
    Public WithEvents AcadApp As AutoCAD.AcadApplication
    Public WithEvents objDWG As AcadDocument


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SetAutoCADApplication()

    End Sub

    Private Sub SetAutoCADApplication()
        On Error Resume Next

        AcadApp = GetObject(, "AutoCAD.Application.16")
        If Err.Number <> 0 Then
            Err.Clear()
            ' Create a new session of AutoCAD 2004 using late binding
            AcadApp = CreateObject("AutoCAD.Application.16")
            If Err.Number <> 0 Then
                MsgBox("Error, could not create a new AutoCAD session")
                End
            End If
        End If
        AcadApp.Visible = True
        objDWG = AcadApp.ActiveDocument

    End Sub

    Private Sub DrawLine()
        Dim objLine As AcadLine
        Dim objCir As AcadCircle
        Dim Point1 As Object
        Dim Point2 As Object
        On Error GoTo Err_Control



        objDWG.Utility.CreateTypedArray(Point1, vbDouble, 20, 20, 0)
        objDWG.Utility.CreateTypedArray(Point2, vbDouble, 0, 0, 0)


        objLine = objDWG.ModelSpace.AddLine(Point1, Point2)
        objCir = objDWG.ModelSpace.AddCircle(Point1, 5)
        objLine.Layer = "New"
        objCir.Layer = "New"

Exit_Here:
        Exit Sub
Err_Control:
        Select Case Err.Number
            Case -2145386476
                'Layer not found
                objDWG.Layers.Add("New")
                Resume
            Case Else
                Debug.Print(Err.Number & ": " & Err.Description)
                Resume Exit_Here
        End Select
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DrawLine()
    End Sub

    Private Sub AcadApp_NewDrawing() Handles AcadApp.NewDrawing
        objDWG = AcadApp.ActiveDocument
    End Sub
End Class

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #3 on: January 04, 2012, 04:19:14 PM »
It seems to me you're using the COM API not the NET API.
Speaking English as a French Frog

ChuckHardin

  • Guest
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #4 on: January 04, 2012, 04:22:24 PM »
Yes I am. That is the only option I have.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #5 on: January 04, 2012, 04:39:43 PM »
So, I'm not sure you can create Palette sets with the COM API as it's possible with the NET API.
Speaking English as a French Frog

zoltan

  • Guest
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #6 on: January 06, 2012, 05:43:00 AM »
There was once a accont16.arx application that would let you put ActiveX controls into a container.

http://www.jrl-e.com/download.htm

Is this what you need?

ChuckHardin

  • Guest
Re: Tool Palettes/Dockable Containers in AutoCAD
« Reply #7 on: January 06, 2012, 05:14:21 PM »
Yes I have it but haven't been able to get it to work in vb.net.
And since I am working with AutoCAD 2004 I would still have to use the COM library in vb.net.
So I guess I will wait till work updates AutoCAD to write stuff for ACAD in .net.