函数是否需要加括号
type类型
出现未定义变量类型错误,怎么破
背景色设置
背景色设置
Sub gg()
Dim myviewer ' As Viewer3D
Set myviewer = CATIA.ActiveWindow.ActiveViewer
Dim color(2)
myviewer.GetBackgroundColor color '当前背景颜色,储存在color中,值为RGB/255,默认为0.2,0.2,0.4
Dim arra(2)
arra(0) = 0.2
arra(1) = 0.2
arra(2) = 0.4
myviewer.PutBackgroundColor arra
End Sub
Dim viewer1
Private Sub CommandButton1_Click()
Dim arra(2)
arra(0) = 0.2
arra(1) = 0.2
arra(2) = 0.4
viewer1.PutBackgroundColor arra
End Sub
Private Sub CommandButton2_Click()
Dim arra(2)
arra(0) = 1
arra(1) = 1
arra(2) = 1
viewer1.PutBackgroundColor arra
End Sub
Private Sub CommandButton3_Click()
If TextBox1.Value < 0 Or TextBox1.Value > 255 Then
MsgBox "请输入0-255之间的RGB值"
Exit Sub
End If
If TextBox2.Value < 0 Or TextBox2.Value > 255 Then
MsgBox "请输入0-255之间的RGB值"
Exit Sub
End If
If TextBox2.Value < 0 Or TextBox2.Value > 255 Then
MsgBox "请输入0-255之间的RGB值"
Exit Sub
End If
Dim arra(2)
arra(0) = Val(TextBox1.Value) / 255
arra(1) = Val(TextBox2.Value) / 255
arra(2) = Val(TextBox3.Value) / 255
viewer1.PutBackgroundColor arra
End Sub
Private Sub UserForm_Initialize()
Set viewer1 = CATIA.ActiveWindow.ActiveViewer
End Sub
检查模块是否封闭
封闭模块,可以fill
Sub CheckFill() '(BoundaryObj As Variant) As Boolean
InitCATIAPart False
Set BoundaryObj = oHBodies.Item(1).HybridShapes.Item(5)
Dim checkf
On Error GoTo NNN
Dim CF As HybridShapeFill
Set CF = oHSF.AddNewFill()
CF.AddBound BoundaryObj
oHBodies.Item(1).AppendHybridShape CF
oPart.UpdateObject CF
checkf = True
Exit Sub
NNN:
checkf = False
End Sub
几何图形集是否存在某一个元素
Attribute VB_Name = "Module3"
Function HybridShapeExists(InputStr As String) As Boolean
On Error GoTo blast
Set curset = hybody1
Set HHH = curset.HybridShapes.Item(InputStr)
HybridShapeExists = True
Exit Function
blast:
HybridShapeExists = False
End Function
Sub f()
init1
Call HybridShapeExists("Point.3")
End Sub