Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Layer Setting in A2K

Status
Not open for further replies.

MarkFry

Mechanical
Mar 12, 2001
41
In R14 I was able to set the layer with a small macro? when using a button by inserting the following text into the command- Layer s `layername';command -but this does not work in 2000. Does anyone know how to write the macro? so it will work in 2000.
 
Replies continue below

Recommended for you

Here is the code:
Code:
Public Sub MakeStdLayer()
    Dim myLayer As AcadLayer, myLineType As AcadLineType
    Dim vColor As Variant, vLineType As Variant
    Dim sName As String
    Dim bFound As Boolean
    
    sName = "OBJ"
    vColor = acGreen
    vLineType = "Continuous"
    
    'Verify that the Linetype is loaded
    For Each myLineType In ThisDrawing.Linetypes
        If myLineType.Name Like CStr(vLineType) Then
            bFound = True
            Exit For
        End If
    Next myLineType
    If bFound = False Then ThisDrawing.Linetypes.Load vLineType, "acad.lin"

    'Create the Layer
    Set myLayer = ThisDrawing.Layers.Add(sName)
    
    myLayer.Color = vColor
    myLayer.Linetype = vLineType
    myLayer.Lineweight = acLnWtByLwDefault
    
    'Clean Up Objects
    Set myLayer = Nothing
    Set myLineType = Nothing
End Sub
Hope this helps!
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
WOW! Way to complicated, but thanks for the reply dsi. Just wanted a little routine to be executed, which would set the layer to say, layer DIM, before executing a dim command ie dimlinear etc.

layer s DIM;_dimlinear (layer set DIM;_dimlinear) is how it was done in R14, this sets the layer to Dim, before executing the dimlinear command, but this does not work in 2000. When you use this routine in 2000, it opens up the layer dialogue box and stops.
 
well what you are doing is called button macros which brocken down is the use of key combinations in order in which you would type the commands

Here cut and past this into the macro area of your button
^C^C-layer s DIM; ;_dimlinear
now you need the 2 spaces between the;; cause they also emulate the enter command
 
the only problem i can for see is if the dim layer is not there then it cannot set it current
if anyoen knows the if then statement to have it create the layer if its not there please post it here in this part of the forum
 
Thanks shadow your right on the money. It work's just fine,
many thanks.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor