AutoCAD 环境设置

Dim oAutoCAD As Object
Call BindAutoCAD(True)

Dim sLayerName As String
Dim iColor As Integer
Dim sTextStyle As String
Dim iMode As Integer

sLayerName = “平面”
iColor = 1 ‘Red
sTextStyle = “汉字”
iMode = 519 ‘端点 1 + 中点 2 + 圆心 4 + 最近点 512

Call AddLayer(sLayerName, iColor)
Call AddTextStyle(sTextStyleName)
Call SetOSMode(iMode)

Public Sub AddLayer(sLayerName As String, iColor As Integer) ‘增加图层
Dim oLayer As Object
Set oLayer = oAutoCAD.ActiveDocument.Layers.Add(sLayerName)
oLayer.Color = iColor
oAutoCAD.ActiveDocument.ActiveLayer = oLayer
End Function

Public Sub AddTextStyle(sTextStyleName As String) ‘添加或修改字体
Dim oTextStyle As Object
Set oTextStyle = oAutoCAD.ActiveDocument.TextStyles.Add(sTextStyleName)
oTextStyle.BigFontFile = “hztxt.shx”
oTextStyle.FontFile = “romans.shx”
oTextStyle.Height = 8
oTextStyle.Width = 0.6
oAutoCAD.ActiveDocument.ActiveTextStyle = oTextStyle
End Function

Public Sub SetOSMode(ByVal iMode As Integer) ‘设置对象捕捉模式
oDraw.SetVariable “OSMODE”, iMode
‘使用以下位码设置“对象捕捉”的模式(OSNAP mode):
‘0 NON (无)
‘1 END(端点)
‘2 MID(中点)
‘4 CEN (圆心)
‘8 NOD (节点)
’16 QUA (象限点)
’32 INT(交点)
’64 INS (插入点)
‘128 PER (垂足)
‘256 Tan (切点)
‘512 NEA (最近点)
‘1024 QUI (快速)
‘2048 App (外观交点)
‘4096 EXT (尺寸线)
‘8192 PAR (平行)
‘要指定多个对象捕捉方式,请输入各个位码值之和。
End Sub

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注