Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to Fold/Unfold a Phisical Product on 3dx

Status
Not open for further replies.

coimbrox

Industrial
Feb 5, 2024
2
i need a macro in vbscript or EKL for plan or unplan a pysical product on my 3dx, a try some ideas but dont worl
i send below a example for my code


Function FindPyshycalProdName() As String
Dim oEditor As Editor
Set oEditor = CATIA.ActiveEditor

Dim oPLMProductService As PLMProductService
Set oPLMProductService = oEditor.GetService("PLMProductService")

Dim oRootOcc As VPMRootOccurrence
Set oRootOcc = oPLMProductService.RootOccurrence

Dim oRootRef As VPMReference
Set oRootRef = oRootOcc.ReferenceRootOccurrenceOf

FindPyshycalProdName = oRootRef.GetAttributeValue("V_Name")
End Function
Sub CATMain()
On Error Resume Next

' Tente obter o documento ativo
Dim oPartDocument As PartDocument
Set oPartDocument = CATIA.ActiveDocument

' Verifique se o documento é uma peça
If Not oPartDocument Is Nothing And oPartDocument.Part.IsKindOf("Part") Then
Dim oPart As Part
Set oPart = oPartDocument.Part

' Tente obter o nome da peça usando a lógica existente
Dim sVNameRootRef As String
sVNameRootRef = ObterNomeDaPeça()

' Selecione a superfície a ser planificada (pode variar conforme a necessidade)
Dim oSurfaces As Selection
Set oSurfaces = oPartDocument.Selection
oSurfaces.Clear
oSurfaces.Search "CATSurf*,all"

' Se a superfície for encontrada
If oSurfaces.Count > 0 Then
Dim oSurface As AnyObject
Set oSurface = oSurfaces.Item(1).Value

' Crie a operação de planificação (unbend)
Dim oUnbendFeature As AnyObject
Set oUnbendFeature = oPart.ShapeFactory.AddNewUnbend(oSurface)

' Execute a operação de planificação
oUnbendFeature.Type = catBendBendPart
oUnbendFeature.Angle = 0
oUnbendFeature.SetFoldingType catBendNoFolding
oUnbendFeature.PropagationType = catConstantBend
oUnbendFeature.IsUpdating = True
oUnbendFeature.Compute

MsgBox "A peça foi planificada com sucesso! Nome da peça: " & sVNameRootRef, vbInformation
Else
MsgBox "Nenhuma superfície selecionada. Selecione uma superfície para planificar.", vbExclamation
End If
Else
MsgBox "Abra um documento de peça no CATIA e tente novamente.", vbExclamation
End If
End Sub

 
Replies continue below

Recommended for you

Status
Not open for further replies.

Part and Inventory Search

Sponsor