xia_jxs 发表于 2009-1-12 16:30:00

[求助]怎样创建填充图形

各位大侠 :<p>&nbsp; 在ATUOLISP中用(command "solid" in_pk31 in_pk30 in_pk32 in_pk31 \)命令可以创建一个</p><p>三角填充图。</p><p>VBA中怎样实现此功能?</p><p>我用下面的命令,系统提示输入点无效</p><p>ThisDrawing.SendCommand "solid" &amp; vbCr &amp; "pick_point_first(0)" &amp; vbCr &amp; "point_arrow(0)" &amp; vbCr &amp; "point_arrow(1)" &amp; vbCr &amp; "pick_point_first(0)" &amp; vbCr<br/></p><p>谢谢各位大侠帮忙</p>

dbczhaoy 发表于 2009-1-14 12:54:00

<p>CAD帮助文件中有这样的代码,稍做修改便可以满足要求:</p><p>Sub Example_AddHatch()<br/>&nbsp;&nbsp;&nbsp; ' This example creates an associative gradient hatch in model space.<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim hatchObj As AcadHatch<br/>&nbsp;&nbsp;&nbsp; Dim patternName As String<br/>&nbsp;&nbsp;&nbsp; Dim PatternType As Long<br/>&nbsp;&nbsp;&nbsp; Dim bAssociativity As Boolean<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; patternName = "CYLINDER"<br/>&nbsp;&nbsp;&nbsp; PatternType = acPreDefinedGradient '0<br/>&nbsp;&nbsp;&nbsp; bAssociativity = True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create the associative Hatch object in model space<br/>&nbsp;&nbsp;&nbsp; Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity, acGradientObject)<br/>&nbsp;&nbsp;&nbsp; Dim col1 As AcadAcCmColor, col2 As AcadAcCmColor<br/>&nbsp;&nbsp;&nbsp; Set col1 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")<br/>&nbsp;&nbsp;&nbsp; Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")<br/>&nbsp;&nbsp;&nbsp; Call col1.SetRGB(255, 0, 0)<br/>&nbsp;&nbsp;&nbsp; Call col2.SetRGB(0, 255, 0)<br/>&nbsp;&nbsp;&nbsp; hatchObj.GradientColor1 = col1<br/>&nbsp;&nbsp;&nbsp; hatchObj.GradientColor2 = col2<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create the outer boundary for the hatch (a circle) 换成三角就可以了<br/>&nbsp;&nbsp;&nbsp; Dim outerLoop(0 To 0) As AcadEntity<br/>&nbsp;&nbsp;&nbsp; Dim center(0 To 2) As Double<br/>&nbsp;&nbsp;&nbsp; Dim radius As Double<br/>&nbsp;&nbsp;&nbsp; center(0) = 3: center(1) = 3: center(2) = 0<br/>&nbsp;&nbsp;&nbsp; radius = 1<br/>&nbsp;&nbsp;&nbsp; Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)</p><p>&nbsp;&nbsp;&nbsp; ' Append the outerboundary to the hatch object, and display the hatch<br/>&nbsp;&nbsp;&nbsp; hatchObj.AppendOuterLoop (outerLoop)<br/>&nbsp;&nbsp;&nbsp; hatchObj.Evaluate<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.Regen True<br/>End Sub</p>
页: [1]
查看完整版本: [求助]怎样创建填充图形