乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 127|回复: 1

[编程交流] 使用设置图层颜色

[复制链接]

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 2022-7-6 22:27:31 | 显示全部楼层 |阅读模式
我正在使用我在某处找到的以下函数来添加新层,并使用VBA为其设置颜色。问题是我想将图层设置为白色,通常只在纸上打印黑色线条。
 
  1. Function CreateLayer(ByVal namelayer As String, ByVal R, G, B As Double)
  2.    On Error Resume Next
  3.    Dim color As AcadAcCmColor
  4.    Dim newlayer As AcadLayer
  5.    'Select Layer or if not exists create a new layer
  6.    Set newlayer = ThisDrawing.Layers.Add(namelayer)
  7.    If Err > 0 Then
  8.    Set newlayer = ThisDrawing.Layers.Item(namelayer)
  9.    Err.Clear
  10.    End If
  11.    'Set AutoCAD Color Objects
  12.    If Left(AutoCAD.Application.ActiveDocument.GetVariable("acadver"), 2) = "16" Then
  13.    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
  14.       
  15.    ElseIf Left(AutoCAD.Application.ActiveDocument.GetVariable("acadver"), 2) = "17" Then
  16.    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
  17.    
  18.    ElseIf Left(AutoCAD.Application.ActiveDocument.GetVariable("acadver"), 2) = "19" Then
  19.    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.19")
  20.    Else
  21.    MsgBox "Wrong Autocad version for this function"
  22.    Exit Function
  23.    End If
  24.    'R,B,G stands for Red, Green, Blue value
  25.    Call color.SetRGB(R, G, B)
  26.    'Create a Layer and make it the active layer
  27.    newlayer.TrueColor = color
  28.    'ThisDrawing.ActiveLayer = newlayer
  29.   
  30. End Function

 
使用本文使用的RGB方法,我传递255、255、255的值,并相应地设置层颜色。但是,这显然不同于将图层设置为白色,结果是设置为255的行、255、255没有在预览或打印机上打印。我尝试了其他一些选择,包括0,0,0,它显示在打印机上,但在模型空间中,黑线太难看到。使用白色作为颜色传递到RGB值的秘密是什么?
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 23:54:32 | 显示全部楼层
FWIW-看起来Oleg使用ColorMethod=acColorMethodByRGB指定了256
 
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 08:53 , Processed in 2.159902 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表