Automatic Section of the Product
Automatic Section of the Product
(OP)
Dear all
I would like to write a script for exporting sections(1mm step in Z directions) of a product. Can you please provide guidance? I can do it manually but i would like to do it automatically. I can provide the command sequence.
I would like to write a script for exporting sections(1mm step in Z directions) of a product. Can you please provide guidance? I can do it manually but i would like to do it automatically. I can provide the command sequence.





RE: Automatic Section of the Product
Option Explicit
' ***********************************************************************
' Purpose : Create a network of sections.
' Assumptions : A CATProduct document should be active.
' Author :
' Languages : VBScript
' Locales : English
' CATIA Level : V5R6
' ***********************************************************************
Dim iNumber ' Number of sections in the network
iNumber = 10
Sub CATMain()
' Retrieve the Sections collection
Dim cSections As Sections
Set cSections = CATIA.ActiveDocument.Product.GetTechnologicalObject("Sections")
' Create the master section
Dim oMasterSection As Section
Set oMasterSection = cSections.Add
' Retrieve data on master section
Dim Position(11)
oMasterSection.GetPosition Position
Dim dHeight As Double
dHeight = oMasterSection.Height
Dim dWidth As Double
dWidth = oMasterSection.Width
Dim dMin As Double
If (dWidth > dHeight) Then
dMin = dWeight
Else
dMin = dWidth
End If
' Remove the master section
cSections.Remove oMasterSection
Set oMasterSection = Nothing
' Create the network
Dim oSection As Section
Position(11) = Position(11) - dMin / 2
Dim I As Integer
For I = 1 To iNumber
' Create section and force type
Set oSection = cSections.Add
oSection.Type = catSectionTypePlane
' Modify position
Position(11) = Position(11) + dMin / iNumber
oSection.SetPosition Position
Set oSection = Nothing
Next
Set cSections = Nothing
End Sub
______
Alex ,
RE: Automatic Section of the Product
Can you please advise on the following 3 things?
1. Change the sectioning step along the Z axis.
2. Can the macro can always start in absolute co ordinates (xy,zy,xy CATIA Planes)
3. Measure the area of each section and export the number in a txt or csv or....
Thank you very much for your help.
Best Regards,
Dimitris
RE: Automatic Section of the Product
CODE -->
Sub CATMain() ' Retrieve the Sections collection Dim cSections As Sections Set cSections = CATIA.ActiveDocument.Product.GetTechnologicalObject("Sections") ' Create the master section Dim oMasterSection As Object 'Section Set oMasterSection = cSections.Add ' Retrieve data on master section Dim Position(11) oMasterSection.GetPosition Position Dim dHeight As Double dHeight = oMasterSection.Height Dim dWidth As Double dWidth = oMasterSection.Width Dim dMin As Double If (dWidth > dHeight) Then dMin = dWeight Else dMin = dWidth End If ' Remove the master section cSections.Remove oMasterSection Set oMasterSection = Nothing ' Create the network Dim oSection As Object 'Section Position(11) = 1 Do ' Create section and force type Set oSection = cSections.Add oSection.Type = catSectionTypePlane ' Modify position Position(11) = Position(11) + 1 oSection.SetPosition Position Indicator = oSection.IsEmpty If Indicator = 0 Then cSections.Remove oSection Else End If Set oSection = Nothing Loop Until Indicator = 0 Set cSections = Nothing End Sub______
Alex ,
RE: Automatic Section of the Product
RE: Automatic Section of the Product
CODE -->
______
Alex ,
RE: Automatic Section of the Product
RE: Automatic Section of the Product
RE: Automatic Section of the Product
Just to create the sections...
CODE --> catvbs
Sub CATMain() Dim cSections Set cSections = CATIA.ActiveDocument.Product.GetTechnologicalObject("Sections") Dim oMasterSection Set oMasterSection = cSections.Add Dim Position(11) oMasterSection.GetPosition Position Dim dHeight dHeight = oMasterSection.Height Dim dWidth dWidth = oMasterSection.Width Dim dMin If (dWidth > dHeight) Then dMin = dWeight Else dMin = dWidth End If cSections.Remove oMasterSection Set oMasterSection = Nothing Dim oSection Position(11) = 0 Do Set oSection = cSections.Add oSection.Type = catSectionTypePlane Position(11) = Position(11) + 1 oSection.SetPosition Position Indicator = oSection.IsEmpty If Indicator = 0 Then cSections.Remove oSection Else End If Set oSection = Nothing Loop Until Indicator = 0 Set cSections = Nothing End Sub______
Alex ,
RE: Automatic Section of the Product