Lukijan,
Never using VB6 I am only guessing.
p.s. if your writing new code, Why not use VBA or vb.net?Code:Set newLayer = ThisDrawing.Layers.Add("NameOfNewLayer") newlayer.color = ... newlayer.linetype = ...
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...


Lukijan,
Never using VB6 I am only guessing.
p.s. if your writing new code, Why not use VBA or vb.net?Code:Set newLayer = ThisDrawing.Layers.Add("NameOfNewLayer") newlayer.color = ... newlayer.linetype = ...
Yeah, but how to make colour palette? I'm making dialog box where user can choose colour for layer, line type, etc.
Thanks, anyway!![]()


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.
ColorLine WeightCode: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
LinetypeCode: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
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
"Potential has a shelf life." - Margaret Atwood
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
Registered forum members do not see this ad.
More on VBA support, from the Autodesk Microsoft Visual Basic for Applications Module FAQ:
Originally Posted by Autodesk, Microsoft Visual Basic for Applications Module FAQ
"Potential has a shelf life." - Margaret Atwood
Bookmarks