I do 95% of my design work within the context of a product. So I have a CATProduct file open and I'm working in a CATPart that is inside that product.
I have created a macro that will run, but only if a CATPart is active. I know how to open the part in a new window and also to test if a Product or Part is active and have the user open in a new window. I really would like to be able to run this with a CATProduct open though. Is there any way that I can do that?? I'm new to programming Catia, so maybe there is an obvious solution.
Here is the macro as it is written now.
Thanks,
Doug
Sub CATMain()
'error handling
On Error Resume Next
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim ScaleVar1 As Variant
ScaleVar1 = InputBox("Enter Scale Factor.", "Input Box", "Scale Factor")
Dim numericCheck As Boolean
numericCheck = IsNumeric(ScaleVar1)
If numericCheck = False Then
MsgBox "Enter a number!"
End
End If
Dim ScaleFactor1 As Double
ScaleFactor1 = CDbl(ScaleVar1)
Dim realParam1 As RealParam
Set realParam1 = parameters1.CreateReal("", ScaleFactor1#)
realParam1.Rename "Scale Factor"
part1.Update
End Sub
I have created a macro that will run, but only if a CATPart is active. I know how to open the part in a new window and also to test if a Product or Part is active and have the user open in a new window. I really would like to be able to run this with a CATProduct open though. Is there any way that I can do that?? I'm new to programming Catia, so maybe there is an obvious solution.
Here is the macro as it is written now.
Thanks,
Doug
Sub CATMain()
'error handling
On Error Resume Next
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim ScaleVar1 As Variant
ScaleVar1 = InputBox("Enter Scale Factor.", "Input Box", "Scale Factor")
Dim numericCheck As Boolean
numericCheck = IsNumeric(ScaleVar1)
If numericCheck = False Then
MsgBox "Enter a number!"
End
End If
Dim ScaleFactor1 As Double
ScaleFactor1 = CDbl(ScaleVar1)
Dim realParam1 As RealParam
Set realParam1 = parameters1.CreateReal("", ScaleFactor1#)
realParam1.Rename "Scale Factor"
part1.Update
End Sub