明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1943|回复: 3

如何修改选择集中对象的属性

[复制链接]
发表于 2005-9-6 16:04:00 | 显示全部楼层 |阅读模式

我想先将选择集中的对象复制 然后再将其图案名改成别的图案,怎么也试验不成功请高手指点! 谢谢

Dim acadDoc As AcadDocument


Private Sub Command1_Click()

On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then End
End If
acadApp.Visible = True
Set acadDoc = acadApp.ActiveDocument
Dim ssetObj As AcadSelectionSet


 K = -1
 For i = 0 To acadDoc.SelectionSets.Count - 1
 If acadDoc.SelectionSets.Item(i).Name = "SSET" Then acadDoc.SelectionSets.Item(i).Delete
  Next i
  Set ssetObj = acadDoc.SelectionSets.Add("SSET")

  Dim corner1(0 To 2) As Double
  Dim corner2(0 To 2) As Double
    corner1(0) = 0: corner1(1) = 0: corner1(2) = 0
    corner2(0) = 200: corner2(1) = 200: corner2(2) = 0

    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    gpCode(0) = 0
    dataValue(0) = "HATCH"
   ' gpCode(1) = 2
   ' dataValue(1) = "SOLID"

    Dim groupCode As Variant, dataCode As Variant
    groupCode = gpCode
    dataCode = dataValue
    ssetObj.Select acSelectionSetAll, , , groupCode, dataCode
  For i = 0 To ssetObj.Count - 1
   ssetObj.Item(i).Move corner1, corner2
  Next i

End Sub

发表于 2005-9-6 20:03:00 | 显示全部楼层
复制用Copy函数
 楼主| 发表于 2005-9-7 08:20:00 | 显示全部楼层

经过研究能考贝了,只能改变颜色,但不能修改图案名 代码如下

Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument


Private Sub Command1_Click()

On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then End
End If
acadApp.Visible = True
Set acadDoc = acadApp.ActiveDocument
Dim ssetObj As AcadSelectionSet
Dim COPYObj As AcadEntity
Dim ss As Object
Dim s1, s2 As AcadHatch
Dim acad_obj As AcadObject

 K = -1
 For i = 0 To acadDoc.SelectionSets.Count - 1
 If acadDoc.SelectionSets.Item(i).Name = "SSET" Then acadDoc.SelectionSets.Item(i).Delete
  Next i
 Set ssetObj = acadDoc.SelectionSets.Add("SSET")

Dim corner1(0 To 2) As Double
  Dim corner2(0 To 2) As Double
    corner1(0) = 0: corner1(1) = 0: corner1(2) = 0
    corner2(0) = 200: corner2(1) = 200: corner2(2) = 0
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    gpCode(0) = 0
    dataValue(0) = "HATCH"
   ' gpCode(1) = 2
   ' dataValue(1) = "SOLID"

    Dim groupCode As Variant, dataCode As Variant
    groupCode = gpCode
    dataCode = dataValue
     ssetObj.Clear
    ssetObj.Select acSelectionSetAll, , , groupCode, dataCode
 Set s1 = ssetObj.Item(0)
 Set s2 = s1.Copy
 ssetObj.Item(0).Move corner1, corner2
 s1.Color = 2
 s2.Color = 1
 MsgBox s2.PatternName
 s2.PatternName = "asni32" '这儿就出错了 说是只读
 ssetObj.Clear
   

End Sub

发表于 2008-2-1 14:46:00 | 显示全部楼层

'图案名改成别的图案

hatchObj.SetPattern acHatchPatternTypePreDefined, "BRICK"

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

本版积分规则

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

GMT+8, 2024-11-26 11:54 , Processed in 0.222542 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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