mycad 发表于 2019-6-27 17:26:50

请教各位老师,大咖有关hatch

请教各位老师,大咖:vba 怎样设置hatc的比例与间距?

Sub Example_AddHatch()    ' This example creates an associative gradient hatch in model space.      Dim hatchObj As AcadHatch    Dim patternName As String    Dim PatternType As Long    Dim bAssociativity As Boolean      ' Define the hatch    patternName = "CYLINDER"    PatternType = acPreDefinedGradient '0    bAssociativity = True      ' Create the associative Hatch object in model space    Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity, acGradientObject)    Dim col1 As AcadAcCmColor, col2 As AcadAcCmColor    Set col1 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.18")    Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.18")    Call col1.SetRGB(255, 0, 0)    Call col2.SetRGB(0, 255, 0)    hatchObj.GradientColor1 = col1    hatchObj.GradientColor2 = col2      ' Create the outer boundary for the hatch (a circle)    Dim outerLoop(0 To 0) As AcadEntity    Dim center(0 To 2) As Double    Dim radius As Double    center(0) = 3: center(1) = 3: center(2) = 0    radius = 1    Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)      ' Append the outerboundary to the hatch object, and display the hatch    hatchObj.AppendOuterLoop (outerLoop)    hatchObj.Evaluate    ThisDrawing.Regen TrueEnd Sub

mycad 发表于 2019-6-28 08:18:00

patternName = "ASIN31"
   
........



hatchObj.PatternScale = 8

lee50310 发表于 2019-7-10 01:54:45

本帖最后由 lee50310 于 2019-7-11 12:41 编辑


要改为图型填充
必须设填充样式 例:
patternName = "ANSI31"            '填充线样式

要改变填充线的比例,间隔,角度就必须从属性设定 例如:
hatchObj.PatternScale = 1          '指定填充比例
hatchObj.PatternSpace = 10      '指定用户自定义填充的间隔
hatchObj.PatternAngle = 120       '指定填充图案的角度.

页: [1]
查看完整版本: 请教各位老师,大咖有关hatch