mark 发表于 2005-7-12 15:07:07

新项目步骤2层

**** Hidden Message *****

Birdy 发表于 2005-7-12 15:09:26

图层名称现在应为“黄色”和“白色”。

Kerry 发表于 2005-7-12 15:21:30

目前...

Public Sub LLayer()
   
    Dim Ylayer As AcadLayer
    Set Ylayer = ThisDrawing.Layers.Add("Yellow")
   
    Dim Wlayer As AcadLayer
    Set Wlayer = ThisDrawing.Layers.Add("White")
   
End Sub

jonesy 发表于 2005-7-12 15:23:28

太好了,现在给图层分配各自的颜色怎么样。有什么想法吗?

Kerry 发表于 2005-7-12 18:22:37

我对你认为应该做些什么来分配颜色感兴趣。 如果您尝试了某些内容,请发布您尝试过的内容。 即使它不起作用,也要发布它,以便其他人可以看到已经尝试过的内容。

Kerry 发表于 2005-7-12 21:01:23

只是注意:任何时候你使用' Set '你应该在sub的末尾把它设置为Nothing。

Kerry 发表于 2005-7-13 21:08:15

在我看来,你应该有一个On Error Goto ErrorH语句,它应该把所有东西都置为空。这样,不管在什么情况下,潜艇都会自己清理。

Birdy 发表于 2005-7-13 23:36:21

我在搞乱这个:
Public Sub LLayer()
    On Error GoTo Error_Handler
    Dim Ylayer As AcadLayer
    Set Ylayer = ThisDrawing.Layers.Add("Yellow")
    Dim Ycolor As ACAD_COLOR
    Set Object.Ycolor = ThisDrawing.Layers.TrueColor("Yellow")
    Set Ylayer = Nothing
   
    Dim Wlayer As AcadLayer
    Set Wlayer = ThisDrawing.Layers.Add("White")
    Set Object.Wcolor = ThisDrawing.Layers.TrueColor("White")
    Set Wlayer = Nothing
    Exit Sub
Error_Handler:
    Err.Clear
    Set Wlayer = Nothing
    Set Ylayer = Nothing
End Sub
但是它不起作用。

Birdy 发表于 2005-7-14 10:13:16

贾斯敏·范登博加尔德,这样怎么样??请记住,在单步执行
代码时,可以使用“局部变量”窗口来查看变量值。
ps:我不是VB'er,所以这可能不是100%

Option Explicit
'
' Test Routine for Demo Only.
'
Public Sub CLLayer()
    On Error GoTo CLLayer_Error
    Dim Ylayer As AcadLayer
    Set Ylayer = ThisDrawing.Layers.Add("Yellow")
    Dim ColorProperty As Integer
    ColorProperty = acYellow
    Ylayer.color = ColorProperty
    ' Could have used :
    ' Ylayer.color = acYellow
    ' to save the declaration and assignment
    '
    ' Next Option
    '
    Dim Glayer As AcadLayer
    Dim TrueColor As New AcadAcCmColor
    Call TrueColor.SetRGB(0, 255, 0)
    Set Glayer = ThisDrawing.Layers.Add("Green")
    Glayer.TrueColor = TrueColor
    '
    '
    ' Next Option
    '
    Dim Newlayer As AcadLayer
    Set Newlayer = ThisDrawing.Layers.Add("FourtyOne")
    Newlayer.color = 41
    '
    ' Added for fun
    '
    Dim aacColor As AcadAcCmColor
    Set aacColor = Newlayer.TrueColor
    Dim strColor As String
    strColor = "Red = " & aacColor.Red & vbCrLf & _
               "Green = " & aacColor.Green & vbCrLf & _
               "Blue = " & aacColor.Blue
    MsgBox strColor
    On Error GoTo 0
    GoTo Set_To_Nothing
CLLayer_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & _
         ") in procedure CLLayer of Module TestLayer"
Set_To_Nothing:
    Set Glayer = Nothing
    Set Ylayer = Nothing
    Set Newlayer = Nothing
    Set aacColor = Nothing
End Sub

Birdy 发表于 2005-7-16 20:07:47

优秀的例子 KWB! 此示例有多种方法可以为图层着色。 每个人都看过不同的方法来做到这一点吗? 大多数人(包括我自己)可能只会认为acad颜色为1-255,但您可能需要其他颜色。
页: [1] 2
查看完整版本: 新项目步骤2层