reutov_tv
Industrial
- Jan 16, 2024
- 33
Hello.
I can't figure out what I need to fix to make the script fill the material field from a user parameter in CatPart (not from PartBody\Material).
Please help.
Thank you.
Piece of code.
I can't figure out what I need to fix to make the script fill the material field from a user parameter in CatPart (not from PartBody\Material).
Please help.
Thank you.
Piece of code.
Code:
ub CATFormatRBText(textName As String, anchorPosition As String)
'-------------------------------------------------------------------------------
'How to format the texts belonging to the titleblock
'-------------------------------------------------------------------------------
Text.Name = textName
Text.AnchorPosition = anchorPosition
Text.SetFontSize 0, 0, 5.
End Sub
Sub CATLinks()
Dim Material_1 As String
'-------------------------------------------------------------------------------
'How to fill in texts with data of the part/product linked with current sheet
'-------------------------------------------------------------------------------
On Error Resume Next
Dim ProductDrawn As ProductDocument
Set ProductDrawn = DrwSheet.Views.Item("Front view").GenerativeBehavior.Document
err.clear
Set ProductDrawn = DrwSheet.Views.Item("Вид спереди").GenerativeBehavior.Document
err.clear
If Err.Number = 0 Then
DrwTexts.GetItem("TitleBlock_Text_Number_1").Text = ProductDrawn.PartNumber
DrwTexts.GetItem("TitleBlock_Text_Number_2").Text = ProductDrawn.PartNumber
DrwTexts.GetItem("TitleBlock_Text_Title").Text = ProductDrawn.Nomenclature
'DrwTexts.GetItem("TitleBlock_Text_Designer_1").Text = ProductDrawn.Revision
'DrwTexts.GetItem("TitleBlock_Text_DDate_1").Text = ProductDrawn.Definition
Dim ProductAnalysis As Analyze
Set ProductAnalysis = ProductDrawn.Analyze
DrwTexts.GetItem("TitleBlock_Text_Weight_1").Text = FormatNumber(ProductAnalysis.Mass,3)
Material_1 = ProductDrawn.Name&"\Material"
err.clear
Material_1 = ProductDrawn.Name&"\Материал"
err.clear
Set Mat_1 = ProductDrawn.Parameters.Item(Material_1)
MM1 = Mat_1.ValueAsString
DrwTexts.GetItem("TitleBlock_Text_Material").Text = Mat_1.ValueAsString
DrwTexts.GetItem("Text_End_Area").Text = intParam1.ValueAsString
End If
'-------------------------------------------------------------------------------
' If No Material
'-------------------------------------------------------------------------------
'MsgBox "MM1иииии="+(MM1)
'MsgBox ProductDrawn.Name&"\Материал" +" nnnnnnnnnnnnnnnnnnnnnnnnnnnnn"
'MsgBox ProductDrawn.Parameters.count
'for i=1 to ProductDrawn.Parameters.count
' MsgBox ProductDrawn.Parameters.item(i).name +" "+ProductDrawn.Parameters.item(i).ValueAsString
'next
If (MM1 <> "") Then
Else
Material_1 = ProductDrawn.Name&"\PartBody\Material"
Set Mat_1 = ProductDrawn.Parameters.Item(Material_1)
MM1 = Mat_1.ValueAsString
DrwTexts.GetItem("TitleBlock_Text_Material").Text = Mat_1.ValueAsString
End If
If (MM1 <> "None") Then
Else
Material_1 = ProductDrawn.Name&"\PartBody\Material"
Set Mat_1 = ProductDrawn.Parameters.Item(Material_1)
MM1 = Mat_1.ValueAsString
DrwTexts.GetItem("TitleBlock_Text_Material").Text = Mat_1.ValueAsString
End If
'-------------------------------------------------------------------------------
'InputBoxNameMaterial
'-------------------------------------------------------------------------------
Dim NewText As DrawingTexts
Dim Variable As String
If (MM1 <> "") Then
Else
Set NewText = DrwTexts.GetItem("TitleBlock_Text_Material")
Variable = InputBox(