Jump to content

Create layer dialog box


Lukijan

Recommended Posts

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...

Link to comment
Share on other sites

Lukijan,

 

Never using VB6 I am only guessing.

 

Set newLayer = ThisDrawing.Layers.Add("NameOfNewLayer")
newlayer.color = ...
newlayer.linetype =  ...

 

p.s. if your writing new code, Why not use VBA or vb.net?

Link to comment
Share on other sites

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

 

Thanks, anyway! :)

Link to comment
Share on other sites

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

    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

  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

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

Link to comment
Share on other sites

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? :unsure:), 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. :thumbsup:

 

HTH

Link to comment
Share on other sites

More on VBA support, from the 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.

 

...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...