明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
123
返回列表 发新帖
楼主: zx79

[求助]铁路线怎么画??

  [复制链接]
发表于 2009-2-11 09:00:00 | 显示全部楼层

因为文件格式不对,压缩后就能上传了

发表于 2009-3-5 22:22:00 | 显示全部楼层

我也试了,的确黑白间隔不等,而且拟合后,有些白色的框框数量减少,导致黑白间隔差距更大,这到底为什么?能有更好的处理方法吗?

发表于 2009-4-5 01:34:00 | 显示全部楼层

绘制铁路线的vba程序,适用于将多条多段线转为铁路线,有兴趣的朋友可以据此改进满足自身需要。

对于样条曲线,直线和圆弧,可以先转为多段线。

Option Explicit
'绘制铁路线
Sub Railway()
    On Error GoTo ErrorHandler

    Dim SSet As AcadSelectionSet
    Set SSet = ThisDrawing.PickfirstSelectionSet
    If SSet.Count = 0 Then
      MsgBox "未选择对象"
      Exit Sub
    End If
   
    AppActivate ThisDrawing.Application.Caption
    Dim Width As Double
    Width = ThisDrawing.Utility.GetReal(vbLf & "请输入铁路线宽: ")
    Dim currLTScale As Double
    currLTScale = ThisDrawing.Utility.GetReal(vbLf & "请输入铁路线型比例: ")
    Dim currLinetype As String
    currLinetype = ThisDrawing.Utility.GetString(False, vbLf & "请输入铁路线型: ")
       
    Dim entry As AcadLineType
    Dim found As Boolean
    found = False
    For Each entry In ThisDrawing.Linetypes
        If StrComp(entry.Name, currLinetype, 1) = 0 Then
            found = True
            Exit For
        End If
    Next
    If Not (found) Then ThisDrawing.Linetypes.Load currLinetype, "acad.lin"

    Dim PlineObj As AcadEntity
    Dim OffsetObj1 As Variant
    Dim OffsetObj2 As Variant
    For Each PlineObj In SSet
      If TypeName(PlineObj) Like "IAcad*Polyline" Then
        OffsetObj1 = PlineObj.Offset(Width / 2)
        OffsetObj2 = PlineObj.Offset(-Width / 2)
        PlineObj.ConstantWidth = Width
        PlineObj.LinetypeScale = currLTScale
        PlineObj.Linetype = currLinetype
        PlineObj.LinetypeGeneration = True
      End If
    Next
    ThisDrawing.Regen True
    Exit Sub
   
ErrorHandler:
  MsgBox Err.Description
   
End Sub

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 07:41 , Processed in 0.158463 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表