乐筑天下

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

无法修改多段线的坐标???

[复制链接]

10

主题

32

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2019-2-18 21:32:00 | 显示全部楼层 |阅读模式
问题描述:写了个类模块OceDoor,图中选择一个矩形多段线后,发现修改多段线坐标后没有反应......
1)以下是 ThisDrawing 里面的代码:
==========================================================================================
Public Sub BBB_GoTestHere()    这个是运行的主过程
Dim SeleObjts As AcadSelectionSet
Dim Objt As Object
Dim Door As New OceDoor
Call CreateSelectionSet(SeleObjts, "Doors"):   SeleObjts.SelectOnScreen
For Each Objt In SeleObjts
  If TypeOf Objt Is AcadLWPolyline Then Set Door.OutLine = Objt
Next Objt
Set SeleObjts = Nothing
Let Door.Width = 5000    这设置宽度,原来宽度是 1200,运行后矩形没变大
End Sub
==========================================================================================
Sub CreateSelectionSet(SeleObjts As AcadSelectionSet, Name As String)
On Error Resume Next
If Not IsNull(ThisDrawing.SelectionSets.Item(Name)) Then
  Set SeleObjts = ThisDrawing.SelectionSets.Item(Name)
  SeleObjts.Delete
End If
Set SeleObjts = ThisDrawing.SelectionSets.Add(Name)
End Sub
==========================================================================================
2)以下是 OceDoor 里面的代码:
Dim Rect As AcadLWPolyline
Dim b0 As Double:  Dim Xc As Double
==========================================================================================
Public Property Set OutLine(ByVal NewValue As AcadLWPolyline)
    Set Rect = NewValue:  Call DataUpdate
End Property
==========================================================================================
Public Property Get OutLine() As AcadLWPolyline
    Set OutLine = Rect
End Property
==========================================================================================
Private Sub DataUpdate()   数据更新
    b0 = Abs(Rect.Coordinate(1)(0) - Rect.Coordinate(3)(0))
    h0 = Abs(Rect.Coordinate(1)(1) - Rect.Coordinate(3)(1))
    Xc = 0.5 * (Rect.Coordinate(1)(0) + Rect.Coordinate(3)(0))
    Yc = 0.5 * (Rect.Coordinate(1)(1) + Rect.Coordinate(3)(1))  
    Rect.Update
End Sub
==========================================================================================
Public Property Get Width() As Double    宽度属性取值
    Width = b0
End Property
==========================================================================================
Public Property Let Width(ByVal NewValue As Double)     宽度属性赋值
    Dim Xmax As Double:  Xmax = Xc + 0.5 * NewValue
    Dim Xmin As Double:  Xmin = Xc - 0.5 * NewValue
    Rect.Coordinate(0)(0) = Xmin:    Rect.Coordinate(2)(0) = Xmax
    Rect.Coordinate(1)(0) = Xmax:   Rect.Coordinate(3)(0) = Xmin
    Call DataUpdate
End Property
回复

使用道具 举报

10

主题

32

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2019-2-19 14:03:00 | 显示全部楼层
简化下代码,这样也无法修改坐标:
Option Explicit
Public Sub BBB_GoTestHere()
Dim SeleObjts As AcadSelectionSet
Dim Objt As Object
Dim Rect As AcadPolyline
Call CreateSelectionSet(SeleObjts, "Polys")
SeleObjts.SelectOnScreen
For Each Objt In SeleObjts
  If TypeOf Objt Is AcadPolyline Then Set Rect = Objt
Next Objt
Set SeleObjts = Nothing
Rect.Coordinates(0) = 5000  '就是这里,根本改不了坐标
End Sub
Sub CreateSelectionSet(SeleObjts As AcadSelectionSet, Name As String)
On Error Resume Next
If Not IsNull(ThisDrawing.SelectionSets.Item(Name)) Then
Set SeleObjts = ThisDrawing.SelectionSets.Item(Name)
SeleObjts.Delete
End If
Set SeleObjts = ThisDrawing.SelectionSets.Add(Name)
End Sub
回复

使用道具 举报

0

主题

58

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
58
发表于 2019-2-21 14:02:00 | 显示全部楼层
  1. Public Property Let Width(ByVal NewValue As Double)   
  2.     Dim Xmax As Double:  Xmax = Xc + 0.5 * NewValue
  3.     Dim Xmin As Double:  Xmin = Xc - 0.5 * NewValue
  4.    
  5.     Dim V(7) As Double
  6.     V(0) = Xmin
  7.     V(1) = Rect.Coordinates(1)
  8.     V(2) = Xmax
  9.     V(3) = Rect.Coordinates(3)
  10.     V(4) = Xmax
  11.     V(5) = Rect.Coordinates(5)
  12.     V(6) = Xmin
  13.     V(7) = Rect.Coordinates(7)
  14.     Rect.Coordinates = V
  15.     Call DataUpdate
  16. End Property


  1. Public Property Let Width(ByVal NewValue As Double)
  2.     Dim Xmax As Double:  Xmax = Xc + 0.5 * NewValue
  3.     Dim Xmin As Double:  Xmin = Xc - 0.5 * NewValue
  4.    
  5.     Dim V(1) As Double
  6.     V(0) = Xmin
  7.     V(1) = Rect.Coordinates(1)
  8.     Rect.Coordinate(0) = V
  9.     V(1) = Rect.Coordinates(7)
  10.     Rect.Coordinate(3) = V
  11.     V(0) = Xmax
  12.     V(1) = Rect.Coordinates(3)
  13.     Rect.Coordinate(1) = V
  14.     V(1) = Rect.Coordinates(5)
  15.     Rect.Coordinate(2) = V
  16.     Call DataUpdate
  17. End Property

回复

使用道具 举报

10

主题

32

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2019-2-21 20:30:00 | 显示全部楼层
就是不能单个坐标这样修改,,,
谢谢!!!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2024-11-22 05:20 , Processed in 0.267747 second(s), 71 queries .

© 2020-2024 乐筑天下

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