我有一个宏,它使用以下代码在SolidWorks工程图中选择一个视图。
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
如何更改此选项以选择名为" Drawing View1
"?
答案 0 :(得分:2)
假设您的swView
对象属于iView
类型,您可以使用GetName2
方法获取名称。因此,您可以使用您已经使用的GetNextView
方法枚举图形中的每个视图,并检查名称是否匹配。
它并没有很好地记录,但是对于它的值,GetNextView
方法在枚举结束后返回空引用指针(例如vb中的nothing
)。
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
Do While Not swView is Nothing
If swView.GetName2 = "Drawing View1" then Exit Do
Set swView = swView.GetNextView
Loop
答案 1 :(得分:1)
即
Dim instance As IModelDocExtension
value = instance.SelectByID2(Name, Type, X, Y, Z, Append, Mark, Callout, SelectOption)
答案 2 :(得分:0)
Set Part = swApp.OpenDoc6(drawpathandfile, 3, 0, "", longstatus, longwarnings)
Dim swDrawing As Object
Set swDrawing = Part
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameLeft = 0
myModelView.FrameTop = 33
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
swApp.ActivateDoc2 "Drawing View1", False, longstatus
Set Part = swApp.ActiveDoc
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized