马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
有谁能帮我将下面的代码翻译是VC的吗?谢谢
Option Explicit
Public Enum swParamType_e ' For use with IAttributeDef::AddParameter (for example)
swParamTypeDouble = 0
swParamTypeString = 1
swParamTypeInteger = 2
swParamTypeDVector = 3
End Enum
Public Enum swInConfigurationOpts_e
swThisConfiguration = 1
swAllConfiguration = 2
swSpecifyConfiguration = 3
End Enum
' 1 = 不可见
' 0 = 可见
Const CreateVisible As Long = 0
Const AttDefName As String = "TDE_XML_string"
Const AttLenDimName As String = "flange_len_dim_name"
Const AttLenValueName As String = "flange_len_value"
Const AttRootName As String = "TDE"
Sub main()
Dim swApp As Object 'SldWorks.SldWorks
Dim swModel As Object 'SldWorks.ModelDoc2
Dim swSelMgr As Object 'SldWorks.SelectionMgr
Dim swFeat As Object
Dim swEnt As Object 'SldWorks.entity
Dim swAttDef As Object 'SldWorks.attributeDef
Dim swAtt As Object 'SldWorks.Attribute
Dim swParamName As Object 'SldWorks.Parameter
Dim swParamValue As Object 'SldWorks.Parameter
Dim AttName As String
Dim i As Long
Dim bRet As Boolean
Dim message1 As String
Dim message As String
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject3(1)
Set swEnt = swFeat
Set swAttDef = swApp.DefineAttribute(AttDefName) '定义属性
bRet = swAttDef.AddParameter(AttLenDimName, swParamTypeString, 0#, 0) '添加参数到属性定义中
bRet = swAttDef.AddParameter(AttLenValueName, swParamTypeDouble, 0#, 0)
bRet = swAttDef.Register '注册 AttributeDef对象
While swAtt Is Nothing
' 获得独一无二的属性名
i = i + 1
AttName = AttRootName + Str(i)
Set swAtt = swAttDef.CreateInstance3(swModel, Nothing, swEnt, AttName, _
CreateVisible, swThisConfiguration) '属性实例
Wend
Set swParamName = swAtt.GetParameter(AttLenDimName) '获得属性的指定参数
Set swParamValue = swAtt.GetParameter(AttLenValueName)
bRet = swParamName.SetStringValue2(AttName & " - " & AttLenDimName, swAllConfiguration, "")
'设置所命名的配置选项参数的字符串
bRet = swParamValue.SetDoubleValue2(i * 10, swAllConfiguration, "") '设置所命名配置选项参数的双精度或整数值
message1 = "文件路径 = " & swModel.GetPathName
If Not swAtt Is Nothing Then
message = " " & AttDefName & "(" & i - 1 & ") = " & AttName
message = message & Chr(10) & "" & Chr(10) & message1
swApp.SendMsgToUser message
Else
Debug.Print " 无法生成属性"
End If
End Sub
::?:-P::l |