End Sub
End Module作者: zhjb113 时间: 2006-11-2 15:54
你录了一段宏之后,你把你的操作UNDO回去,然后你再执行宏,你就会看到你的操作会被重新执行了作者: cam-yp 时间: 2006-11-2 16:17
楼上的。。。。高!作者: vodka 时间: 2006-11-3 01:55
' Collector是NX4开始新增加的对象,用来收集全部需要倒角的Edge
Dim scCollector1 As ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector()
Dim seedEdges1(0) As Edge
' Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(0)"), Features.Block)
' Dim edge1 As Edge = CType(block1.FindObject("EDGE * 4 * 1"), Edge)
Dim edge1 As Edge ....' 调用selection子程序
seedEdges1(0) = edge1
' 收集规则
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)
Dim scCollector1 As ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector() //创建一个ScCllector 赋给ScCllector1 (ScCllector 是什么??)
Dim seedEdges1(0) As Edge
Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(0)"), Features.Block) //寻找 BLOCK 并把它转化为Features.Block类型
Dim edge1 As Edge = CType(block1.FindObject("EDGE * 4 * 1"), Edge)//在BLOCK上寻找要倒圆的边,并转化为Edge类型
seedEdges1(0) = edge1
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)// 创建一个倒圆规则 赋给edgeMultipleSeedTangentRule1 (不知道ScRuleFactory是作什么用的??)
Dim rules1(0) As SelectionIntentRule ///SelectionIntentRule 这个类是作什么用的???
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False) //为什么要ReplaceRules???
Dim markId2 As Session.UndoMarkId ///不明白??
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Edge Blend")//不明白??
edgeBlendBuilder1.Tolerance = 0.0254
Try
ufs.Ui.SelectWithClassDialog(prompt, "Curves:", _
UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, _
mask_crvs, Nothing, response, cnt, curves)
' For inx = 0 To curves.Length - 1
' Dim blend1 As New UFModl.EdgeBlendData
' ufs.Modl.AskEdgeBlend(curves(inx), blend1)
' ufs.Modl.CreateEdgeBlend(blend1, output)
' Next
Finally
ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
' For inx = 0 To curves.Length - 1
' ufs.Disp.SetHighlight(curves(inx), 0)
' Next
'===========================================================
Dim workPart As Part = s.Parts.Work
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim edgeBlendBuilder1 As Features.EdgeBlendBuilder
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature)
Dim scCollector1 As ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector()
Dim seedEdges1(0) As Edge
'Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(0)"), Features.Block) '替换
Dim edge1 As Edge = CType(NXObjectManager.Get(curves(inx)), Edge) '替换
seedEdges1(0) = edge1
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)
Dim rules1(0) As SelectionIntentRule
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False)
至于后面的builder,是因为你又执行了一次blend,系统给你产生了一段代码,但是你有中止了,所以后面就没有了作者: 昆山人 时间: 2006-11-3 14:13
多谢楼上大哥详尽的解答,懂得了不少.
上面的程序我只能倒一条边,现在我想倒几条边,我在里面加了一个循环,可是老是出错,下面红色的部分
就是我添加的循环,
........
........
Dim edge1() As Edge
Dim seedEdges1(100) As Edge
For inx = 0 To curves.Length - 1
If inx > 0 Then
For x = 0 To inx - 1
seedEdges1(x) = edge1(x)
Next
End If
Dim edge2 As Edge = CType(NXObjectManager.Get(curves(inx)), Edge)
edge1(inx) = edge2
seedEdges1(inx) = edge1(inx)
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)
Dim rules1(0) As SelectionIntentRule
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False)
' ----------------------------------------------
' Menu: Insert->Detail Feature->Edge Blend...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim edgeBlendBuilder1 As Features.EdgeBlendBuilder
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature)
theSession.SetUndoMarkName(markId1, "Edge Blend")
Dim scCollector1 As ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector()
'================================
Dim seedEdges1(0) As Edge
Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(0)"), Features.Block)
Dim edge1 As Edge = CType(block1.FindObject("EDGE * 2 * 6"), Edge)
seedEdges1(0) = edge1
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)
Dim rules1(0) As SelectionIntentRule
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False)
'================================
Dim seedEdges2(1) As Edge
seedEdges2(0) = edge1
Dim edge2 As Edge = CType(block1.FindObject("EDGE * 2 * 5"), Edge)
seedEdges2(1) = edge2
Dim edgeMultipleSeedTangentRule2 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule2 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges2, 0.5, True)
Dim rules2(0) As SelectionIntentRule
rules2(0) = edgeMultipleSeedTangentRule2
scCollector1.ReplaceRules(rules2, False)
'=================================
Dim seedEdges3(2) As Edge
seedEdges3(0) = edge1
seedEdges3(1) = edge2
Dim edge3 As Edge = CType(block1.FindObject("EDGE * 6 * 5"), Edge)
seedEdges3(2) = edge3
Dim edgeMultipleSeedTangentRule3 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule3 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges3, 0.5, True)
Dim rules3(0) As SelectionIntentRule
rules3(0) = edgeMultipleSeedTangentRule3
scCollector1.ReplaceRules(rules3, False)
'==================================
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Edge Blend")
我再试试看作者: 昆山人 时间: 2006-11-3 15:22
我用了一种比较简单的办法来倒几个角..循环加在最外面,如下面红色的.可以倒圆...可是完了后会出来一个错误提示,见附件
======================
..........
.........
选择EDGE
......
Try
For inx = 0 To curves.Length ''new add Dim workPart As Part = s.Parts.Work
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim edgeBlendBuilder1 As Features.EdgeBlendBuilder
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature)
Dim scCollector1 As ScCollector
scCollector1 = workPart.ScCollectors.CreateCollector()
Dim seedEdges1(0) As Edge
'Dim block1 As Features.Block = CType(workPart.Features.FindObject("BLOCK(0)"), Features.Block) '替换
Dim edge1 As Edge = CType(NXObjectManager.Get(curves(inx)), Edge) '替换
seedEdges1(0) = edge1
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, True)
Dim rules1(0) As SelectionIntentRule
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False)