eduardopinto07
Automotive
I find out how to insert and read the x,y and z values of a local sensor by macro.
So, for those who want to do it...
Sub CATMain()
Dim analysisDocument1 As AnalysisDocument
Set analysisDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = analysisDocument1.Selection
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = selection1.VisProperties
Set visPropertySet1 = visPropertySet1.Parent
visPropertySet1.SetShow 0
selection1.Clear
Dim analysisManager1 As AnalysisManager
Set analysisManager1 = analysisDocument1.Analysis
Dim analysisLinkedDocuments1 As AnalysisLinkedDocuments
Set analysisLinkedDocuments1 = analysisManager1.LinkedDocuments
Dim partDocument1 As PartDocument
Set partDocument1 = analysisLinkedDocuments1.Item(1)
Dim product1 As Product
Set product1 = partDocument1.Product
Dim analysisModels1 As AnalysisModels
Set analysisModels1 = analysisManager1.AnalysisModels
Dim analysisModel1 As AnalysisModel
Set analysisModel1 = analysisModels1.Item(1)
Dim analysisCases1 As AnalysisCases
Set analysisCases1 = analysisModel1.AnalysisCases
Dim analysisCase1 As AnalysisCase
Set analysisCase1 = analysisCases1.Item(1)
Dim analysisSets1 As AnalysisSets
Set analysisSets1 = analysisCase1.AnalysisSets
Dim analysisSet1 As AnalysisSet
Set analysisSet1 = analysisSets1.ItemByType("SensorSet")
Dim analysisEntities1 As AnalysisEntities
Set analysisEntities1 = analysisSet1.AnalysisEntities
' ---------------------------------------
'Creation of local sensor
' ---------------------------------------
Dim analysisLocalSensor1 As AnalysisLocalSensor
Set analysisLocalSensor1 = analysisEntities1.Add("SAMImageSensor")
' ---------------------------------------
' We set the support of the local sensor
' ---------------------------------------
Dim part1 As Part
Set part1 = partDocument1.Part
Dim orderedGeometricalSets1 As OrderedGeometricalSets
Set orderedGeometricalSets1 = part1.OrderedGeometricalSets
Dim orderedGeometricalSet1 As OrderedGeometricalSet
Set orderedGeometricalSet1 = orderedGeometricalSets1.Item("Ordered Geometrical Set.1")
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = orderedGeometricalSet1.HybridShapes
Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapes1.Item("Point.1")
Set hybridShapes1 = hybridShapePointCoord1.Parent
Dim reference1 As Reference
Set reference1 = hybridShapes1.Item("Point.1")
analysisLocalSensor1.AddSupportFromProduct product1, reference1
analysisLocalSensor1.XMLName = "Sensor_Disp"
analysisLocalSensor1.Name = "Displacement Vector"
Dim analysisSet2 As AnalysisSet
Set analysisSet2 = analysisSets1.ItemByType("StaticSet")
Dim reference2 As Reference
Set reference2 = analysisManager1.CreateReferenceFromObject(analysisSet2)
Set reference2 = reference2.Parent
Dim basicComponents1 As BasicComponents
Set basicComponents1 = analysisLocalSensor1.BasicComponents
Dim basicComponent1 As BasicComponent
Set basicComponent1 = basicComponents1.GetItem("SAMOccSolutionFilter.1")
Dim basicComponents2 As BasicComponents
Set basicComponents2 = basicComponent1.BasicComponents
Dim basicComponent2 As BasicComponent
Set basicComponent2 = basicComponents2.GetItem("SAMSolutionPtr.1")
basicComponent2.SetReference "ConnectorList", 0, 0, 0, reference2
Debug.Print analysisLocalSensor1.OutPutParameters.Item(1).ValueAsString
Debug.Print analysisLocalSensor1.OutPutParameters.Item(2).ValueAsString
Debug.Print analysisLocalSensor1.OutPutParameters.Item(3).ValueAsString
'List of available local sensors names (XMLName):
'.
'GPS Product:
'.
'Sensor_Disp_Iso :- Displacement Magnitude
'Sensor_Disp :- Displacement Vector
'Relative_Sensor_Disp :- Relative DisplacementVector
'Sensor_Rotation :- Rotation Vector
'Sensor_Stress_VonMises :- Von Mises Stress
'Sensor_EstimatedError :- Error
'.
'EST Product:
'.
'Sensor_Stress_SymTensor :- Stress Tensor
'Sensor_Stress_PpalShearing :- Principal Shearing
'Sensor_Stress_PpalTensor :- Principal StressTensor
'Sensor_Strain_PpalTensor :- Principal Strain Tensor
'Sensor_Strain_SymTensor :- Strain Tensor
'Sensor_Force :- Force
'Sensor_Moment :- Moment
'Sensor_ElasticEnergy :- Elastic Energy
'Sensor_Display_clearance :- Clearance
'Sensor_Acceleration :- Acceleration Vector
'Relative_Sensor_Acceleratio :- RelativeAcceleration Vector
'Sensor_Velocity :- Velocity Vector
'Relative_Sensor_Velocity :- Relative Velocity Vector
'Surface_Sensor_Stress_SymTensor :- SurfaceStress Tensor
'Surface_Sensor_Stress_PpalTensor :- SurfacePrincipal Stress Tensor
analysisLocalSensor1.Update
End Sub
So, for those who want to do it...
Sub CATMain()
Dim analysisDocument1 As AnalysisDocument
Set analysisDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = analysisDocument1.Selection
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = selection1.VisProperties
Set visPropertySet1 = visPropertySet1.Parent
visPropertySet1.SetShow 0
selection1.Clear
Dim analysisManager1 As AnalysisManager
Set analysisManager1 = analysisDocument1.Analysis
Dim analysisLinkedDocuments1 As AnalysisLinkedDocuments
Set analysisLinkedDocuments1 = analysisManager1.LinkedDocuments
Dim partDocument1 As PartDocument
Set partDocument1 = analysisLinkedDocuments1.Item(1)
Dim product1 As Product
Set product1 = partDocument1.Product
Dim analysisModels1 As AnalysisModels
Set analysisModels1 = analysisManager1.AnalysisModels
Dim analysisModel1 As AnalysisModel
Set analysisModel1 = analysisModels1.Item(1)
Dim analysisCases1 As AnalysisCases
Set analysisCases1 = analysisModel1.AnalysisCases
Dim analysisCase1 As AnalysisCase
Set analysisCase1 = analysisCases1.Item(1)
Dim analysisSets1 As AnalysisSets
Set analysisSets1 = analysisCase1.AnalysisSets
Dim analysisSet1 As AnalysisSet
Set analysisSet1 = analysisSets1.ItemByType("SensorSet")
Dim analysisEntities1 As AnalysisEntities
Set analysisEntities1 = analysisSet1.AnalysisEntities
' ---------------------------------------
'Creation of local sensor
' ---------------------------------------
Dim analysisLocalSensor1 As AnalysisLocalSensor
Set analysisLocalSensor1 = analysisEntities1.Add("SAMImageSensor")
' ---------------------------------------
' We set the support of the local sensor
' ---------------------------------------
Dim part1 As Part
Set part1 = partDocument1.Part
Dim orderedGeometricalSets1 As OrderedGeometricalSets
Set orderedGeometricalSets1 = part1.OrderedGeometricalSets
Dim orderedGeometricalSet1 As OrderedGeometricalSet
Set orderedGeometricalSet1 = orderedGeometricalSets1.Item("Ordered Geometrical Set.1")
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = orderedGeometricalSet1.HybridShapes
Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapes1.Item("Point.1")
Set hybridShapes1 = hybridShapePointCoord1.Parent
Dim reference1 As Reference
Set reference1 = hybridShapes1.Item("Point.1")
analysisLocalSensor1.AddSupportFromProduct product1, reference1
analysisLocalSensor1.XMLName = "Sensor_Disp"
analysisLocalSensor1.Name = "Displacement Vector"
Dim analysisSet2 As AnalysisSet
Set analysisSet2 = analysisSets1.ItemByType("StaticSet")
Dim reference2 As Reference
Set reference2 = analysisManager1.CreateReferenceFromObject(analysisSet2)
Set reference2 = reference2.Parent
Dim basicComponents1 As BasicComponents
Set basicComponents1 = analysisLocalSensor1.BasicComponents
Dim basicComponent1 As BasicComponent
Set basicComponent1 = basicComponents1.GetItem("SAMOccSolutionFilter.1")
Dim basicComponents2 As BasicComponents
Set basicComponents2 = basicComponent1.BasicComponents
Dim basicComponent2 As BasicComponent
Set basicComponent2 = basicComponents2.GetItem("SAMSolutionPtr.1")
basicComponent2.SetReference "ConnectorList", 0, 0, 0, reference2
Debug.Print analysisLocalSensor1.OutPutParameters.Item(1).ValueAsString
Debug.Print analysisLocalSensor1.OutPutParameters.Item(2).ValueAsString
Debug.Print analysisLocalSensor1.OutPutParameters.Item(3).ValueAsString
'List of available local sensors names (XMLName):
'.
'GPS Product:
'.
'Sensor_Disp_Iso :- Displacement Magnitude
'Sensor_Disp :- Displacement Vector
'Relative_Sensor_Disp :- Relative DisplacementVector
'Sensor_Rotation :- Rotation Vector
'Sensor_Stress_VonMises :- Von Mises Stress
'Sensor_EstimatedError :- Error
'.
'EST Product:
'.
'Sensor_Stress_SymTensor :- Stress Tensor
'Sensor_Stress_PpalShearing :- Principal Shearing
'Sensor_Stress_PpalTensor :- Principal StressTensor
'Sensor_Strain_PpalTensor :- Principal Strain Tensor
'Sensor_Strain_SymTensor :- Strain Tensor
'Sensor_Force :- Force
'Sensor_Moment :- Moment
'Sensor_ElasticEnergy :- Elastic Energy
'Sensor_Display_clearance :- Clearance
'Sensor_Acceleration :- Acceleration Vector
'Relative_Sensor_Acceleratio :- RelativeAcceleration Vector
'Sensor_Velocity :- Velocity Vector
'Relative_Sensor_Velocity :- Relative Velocity Vector
'Surface_Sensor_Stress_SymTensor :- SurfaceStress Tensor
'Surface_Sensor_Stress_PpalTensor :- SurfacePrincipal Stress Tensor
analysisLocalSensor1.Update
End Sub