+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Junior Member
    Using
    not applicable
    Join Date
    Jun 2012
    Posts
    12

    Default Create layer dialog box

    Registered forum members do not see this ad.

    Hi everybody!

    I'm trying to create dialog box for creating new layer, I googled everything I could remember, but I can't find anything.

    Set newLayer = ThisDrawing.Layers.Add("NameOfNewLayer")

    should create new layer, but how to define color or weight or type of lines?

    P.S. I'm using VB6...

  2. #2
    Senior Member
    Computer Details
    flowerrobot's Computer Details
    Operating System:
    Windowns 7
    Computer:
    Lenovo W520
    Discipline
    Mechanical
    flowerrobot's Discipline Details
    Occupation
    Cad Manger
    Discipline
    Mechanical
    Using
    Mechanical 2013
    Join Date
    Sep 2007
    Location
    Sydney
    Posts
    384

    Default

    Lukijan,

    Never using VB6 I am only guessing.

    Code:
    Set newLayer = ThisDrawing.Layers.Add("NameOfNewLayer")
    newlayer.color = ...
    newlayer.linetype =  ...
    p.s. if your writing new code, Why not use VBA or vb.net?

  3. #3
    Junior Member
    Using
    not applicable
    Join Date
    Jun 2012
    Posts
    12

    Default

    Yeah, but how to make colour palette? I'm making dialog box where user can choose colour for layer, line type, etc.

    Thanks, anyway!

  4. #4
    Senior Member
    Computer Details
    flowerrobot's Computer Details
    Operating System:
    Windowns 7
    Computer:
    Lenovo W520
    Discipline
    Mechanical
    flowerrobot's Discipline Details
    Occupation
    Cad Manger
    Discipline
    Mechanical
    Using
    Mechanical 2013
    Join Date
    Sep 2007
    Location
    Sydney
    Posts
    384

    Default

    I recently looked into this, It is quite hard, When not using Arx.

    I do have code to create a Custom ComboBox for colors, but could not get the linetype bitmaps to work. I can give you the code if you like.
    The best solution I came up with was to use the AutoCAD Dialogue boxes. Linked to a datagrid form.

    Color
    Code:
        Public Function UserGetColor() As Autodesk.AutoCAD.Colors.Color
            Dim DiaLineWT As New Autodesk.AutoCAD.Windows.ColorDialog
            Dim Result As System.Windows.Forms.DialogResult = DiaLineWT.ShowModal()
            If Result = System.Windows.Forms.DialogResult.OK Then
                Return DiaLineWT.Color
            Else
                Return Nothing
            End If
        End Function
    Line Weight
    Code:
      Public Shared Function UserGetLineWeight() As LineWeight
            Dim DiaLineWT As New Autodesk.AutoCAD.Windows.LineWeightDialog
            Dim Result As System.Windows.Forms.DialogResult = DiaLineWT.ShowModal()
            If Result = System.Windows.Forms.DialogResult.OK Then
                Return DiaLineWT.LineWeight
            Else
                Return Nothing
            End If
        End Function
    Linetype
    Code:
    Shared Function UserGetLineType() As LinetypeTableRecord
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Try
                Using tr As Transaction = db.TransactionManager.StartTransaction
                    Dim ltt As LinetypeTable = tr.GetObject(db.LinetypeTableId, OpenMode.ForRead)
                    Dim ltID As ObjectId = ShowLineTypeDialog()
                    Dim ltr As LinetypeTableRecord = TryCast(tr.GetObject(ltID, OpenMode.ForRead, False), LinetypeTableRecord)
                    If ltr IsNot Nothing Then
                        Return ltr
                    Else
                        Return Nothing
                    End If
                End Using
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                doc.Editor.WriteMessage(ex.Message)
                Return Nothing
            End Try
        End Function

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    4,039
    "Potential has a shelf life." - Margaret Atwood

  6. #6
    Junior Member
    Using
    not applicable
    Join Date
    Jun 2012
    Posts
    12

    Default

    I'm using VB6, not VB.NET :/

  7. #7
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    4,039

    Default

    Quote Originally Posted by Lukijan View Post
    I'm using VB6, not VB.NET :/
    FWIW -

    Microsoft no longer supports VBA, and even Autodesk only provides access to VBAIDE via a separate download (it's no longer included with AutoCAD products).

    Presumably at some point (in the far future? ), VBA is going to die off through attrition, unless a rumored 'VBA7' is released. Keep that in mind when deciding which platform on which to develop your initiatives. Were Autodesk to stop offering the VBAIDE separate install, you'd be in a pinch.

    To that end, .NET & ObjectARX are quickly becoming Autodesk's development platforms of choice.

    You'd do well to start looking into it for that reason, and for accessing many of the new API Features that are only being exposed to .NET and ObjectARX. For simpler routines that you'd normally do in VBA, consider Visual LISP, as it also uses the ActiveX API.

    HTH
    "Potential has a shelf life." - Margaret Atwood

  8. #8
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    4,039

    Default

    Registered forum members do not see this ad.

    More on VBA support, from the Autodesk Microsoft Visual Basic for Applications Module FAQ:

    Quote Originally Posted by Autodesk, Microsoft Visual Basic for Applications Module FAQ


    What is the status of VBA support in the most recent releases of the AutoCAD product line?

    Microsoft made the decision to stop offering VBA distribution licenses to new customers as of July 1, 2007 and they have expressed that there are no plans to provide VBA product enhancements in the future. As a result of this, though Autodesk will continue to “unofficially” support VBA in its most recent releases of the products, software developers are strongly encouraged to base all future Microsoft Windows based development for AutoCAD based products on the Microsoft .NET Framework (VB .NET, C#, managed C++ etc).

    As first introduced with AutoCAD 2010, AutoCAD is not distributing VBA as part of the most recent AutoCAD installation disk. Rather, customers will need to download VBA here.


    What do you mean “unofficial” support for VBA?

    We will continue offering VBA as a download for customers, however, because Microsoft has discontinued support, we will only make a best efforts attempt to fix any defects and do not plan enhancements to VBA support in future product releases.


    What do you recommend for non-programmers to create simple scripts? .NET looks significantly harder to use than VBA.

    Though a little bit longer learning curve, we strongly recommend non-programmer’s get started customizing AutoCAD based on VB .NET using the free Microsoft VB Express. Developing .NET based applications with VB Express is a great no cost way to get started customizing AutoCAD that is easily extended if and when one wants to develop more powerful add-ons for AutoCAD.

    ...
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. Layer Dialog Box Highlight on Layer Name
    By rdevans in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 27th Apr 2012, 05:56 pm
  2. Replies: 4
    Last Post: 5th Jan 2011, 07:39 pm
  3. How to Create Lisp Dialog Box???
    By balajibth84 in forum AutoLISP, Visual LISP & DCL
    Replies: 34
    Last Post: 22nd Oct 2010, 07:55 pm
  4. help me create display a dialog listing all commands & lisp
    By autolisp in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 21st Jul 2010, 08:49 am
  5. Create New Drawing Dialog Box
    By nicnicman in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 19th Oct 2008, 10:51 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts