291118 发表于 2005-9-6 16:04:00

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

<P>我想先将选择集中的对象复制 然后再将其图案名改成别的图案,怎么也试验不成功请高手指点! 谢谢</P>
<P>Dim acadDoc As AcadDocument</P>
<P><BR>Private Sub Command1_Click()</P>
<P>On Error Resume Next<BR>Set acadApp = GetObject(, "AutoCAD.Application")<BR>If Err Then<BR>Err.Clear<BR>Set acadApp = CreateObject("AutoCAD.Application")<BR>If Err Then End<BR>End If<BR>acadApp.Visible = True<BR>Set acadDoc = acadApp.ActiveDocument<BR>Dim ssetObj As AcadSelectionSet</P>
<P><BR>&nbsp;K = -1<BR>&nbsp;For i = 0 To acadDoc.SelectionSets.Count - 1<BR>&nbsp;If acadDoc.SelectionSets.Item(i).Name = "SSET" Then acadDoc.SelectionSets.Item(i).Delete<BR>&nbsp; Next i<BR>&nbsp; Set ssetObj = acadDoc.SelectionSets.Add("SSET")</P>
<P>&nbsp; Dim corner1(0 To 2) As Double<BR>&nbsp; Dim corner2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; corner1(0) = 0: corner1(1) = 0: corner1(2) = 0<BR>&nbsp;&nbsp;&nbsp; corner2(0) = 200: corner2(1) = 200: corner2(2) = 0</P>
<P>&nbsp;&nbsp;&nbsp; Dim gpCode(0) As Integer<BR>&nbsp;&nbsp;&nbsp; Dim dataValue(0) As Variant<BR>&nbsp;&nbsp;&nbsp; gpCode(0) = 0<BR>&nbsp;&nbsp;&nbsp; dataValue(0) = "HATCH"<BR>&nbsp;&nbsp; ' gpCode(1) = 2<BR>&nbsp;&nbsp; ' dataValue(1) = "SOLID"</P>
<P>&nbsp;&nbsp;&nbsp; Dim groupCode As Variant, dataCode As Variant<BR>&nbsp;&nbsp;&nbsp; groupCode = gpCode<BR>&nbsp;&nbsp;&nbsp; dataCode = dataValue<BR>&nbsp;&nbsp;&nbsp; ssetObj.Select acSelectionSetAll, , , groupCode, dataCode<BR>&nbsp; For i = 0 To ssetObj.Count - 1<BR>&nbsp;&nbsp; ssetObj.Item(i).Move corner1, corner2<BR>&nbsp; Next i</P>
<P>End Sub</P>

雪山飞狐_lzh 发表于 2005-9-6 20:03:00

复制用Copy函数

291118 发表于 2005-9-7 08:20:00

<P>经过研究能考贝了,只能改变颜色,但不能修改图案名 代码如下</P>
<P>Dim acadApp As AcadApplication<BR>Dim acadDoc As AcadDocument</P>
<P><BR>Private Sub Command1_Click()</P>
<P>On Error Resume Next<BR>Set acadApp = GetObject(, "AutoCAD.Application")<BR>If Err Then<BR>Err.Clear<BR>Set acadApp = CreateObject("AutoCAD.Application")<BR>If Err Then End<BR>End If<BR>acadApp.Visible = True<BR>Set acadDoc = acadApp.ActiveDocument<BR>Dim ssetObj As AcadSelectionSet<BR>Dim COPYObj As AcadEntity<BR>Dim ss As Object<BR>Dim s1, s2 As AcadHatch<BR>Dim acad_obj As AcadObject</P>
<P>&nbsp;K = -1<BR>&nbsp;For i = 0 To acadDoc.SelectionSets.Count - 1<BR>&nbsp;If acadDoc.SelectionSets.Item(i).Name = "SSET" Then acadDoc.SelectionSets.Item(i).Delete<BR>&nbsp; Next i<BR>&nbsp;Set ssetObj = acadDoc.SelectionSets.Add("SSET")</P>
<P>Dim corner1(0 To 2) As Double<BR>&nbsp; Dim corner2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; corner1(0) = 0: corner1(1) = 0: corner1(2) = 0<BR>&nbsp;&nbsp;&nbsp; corner2(0) = 200: corner2(1) = 200: corner2(2) = 0<BR>&nbsp;&nbsp;&nbsp; Dim gpCode(0) As Integer<BR>&nbsp;&nbsp;&nbsp; Dim dataValue(0) As Variant<BR>&nbsp;&nbsp;&nbsp; gpCode(0) = 0<BR>&nbsp;&nbsp;&nbsp; dataValue(0) = "HATCH"<BR>&nbsp;&nbsp; ' gpCode(1) = 2<BR>&nbsp;&nbsp; ' dataValue(1) = "SOLID"</P>
<P>&nbsp;&nbsp;&nbsp; Dim groupCode As Variant, dataCode As Variant<BR>&nbsp;&nbsp;&nbsp; groupCode = gpCode<BR>&nbsp;&nbsp;&nbsp; dataCode = dataValue<BR>&nbsp;&nbsp;&nbsp;&nbsp; ssetObj.Clear<BR>&nbsp;&nbsp;&nbsp; ssetObj.Select acSelectionSetAll, , , groupCode, dataCode<BR>&nbsp;Set s1 = ssetObj.Item(0)<BR>&nbsp;Set s2 = s1.Copy<BR>&nbsp;ssetObj.Item(0).Move corner1, corner2<BR>&nbsp;s1.Color = 2<BR>&nbsp;s2.Color = 1<BR>&nbsp;MsgBox s2.PatternName<BR>&nbsp;s2.PatternName = "asni32" '这儿就出错了 说是只读<BR>&nbsp;ssetObj.Clear<BR>&nbsp;&nbsp;&nbsp; </P>
<P>End Sub<BR></P>

wenwengg 发表于 2008-2-1 14:46:00

<p>'图案名改成别的图案</p><p><font style="BACKGROUND-COLOR: #b2b4bf;">hatchObj</font>.SetPattern acHatchPatternTypePreDefined, "BRICK"<br/></p>
页: [1]
查看完整版本: 如何修改选择集中对象的属性