Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Querying for a List of Electrical Objects

Status
Not open for further replies.

MahPLM

Computer
Jun 22, 2016
6
TN
Hello,
I try writing a macro (and also a vb.net project)to extract electrical objects information from a Catia assembly (wires: number, length...)using the ElectricalTypeLib library.
But I can't access to any ElectricalObject.
Any help please ?
Thanks.
 
Replies continue below

Recommended for you

Hello,
What do you use to access those objects? Can you post your code plz?
 
Hello AtomicNico,
Thank you for your rapid response.
I try to write something like this :

Imports ProductStructureTypeLib
Imports ElectricalTypeLib

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim CATIA As INFITF.Application

CATIA = GetObject(, "CATIA.Application")

If Err.Number = 0 Then

CATIA = CreateObject("CATIA.Application")

CATIA.Visible = True

End If

Dim Doc As ProductDocument
Doc = CATIA.ActiveDocument

Dim Prod As Product
Prod = Doc.Product

Dim path As String
path = Doc.Path

Datos = CATIA.FileSystem.CreateFile(path & "\" & CATIA.ActiveDocument.Name & ".xml", True)

ostream = Datos.OpenAsTextStream("ForAppending")

Try

Dim obj As ElectricalObject

Dim selection1 As Object

selection1 = Doc.Selection

selection1.Search("ElectricalObject")


For I = 1 To selection1.Count

obj = selection1.Item(I).Value

ostream.Write "Name" & selection1.Item(I).Name & ",Type" & selection1.Item(I).Type

Next

ostream.Write CATIA.ActiveDocument.Name & Chr(10)

ostream.Close()


Catch ex As Exception
TextBox1.Text = ex.ToString
End Try

End Sub
End Class

****
Any help please ?
Regards
 
Hello MahPLM,
Just to be sure: you're writing this macro inside CATIA or outside on Visual Studio or VBA?

selection1.Search("ElectricalObject")
Are you sure "ElectricalObject" is the real name given by Dassault?
Moreover, I think you should add ,all to be sure you select everything
selection1.Search("ElectricalObject, all")

Here is a little macro to test the type of the selected object:
Code:
Sub CATMain()
Msgbox Typename(CATIA.Activedocument.Selection.Item2(1).Value)
End Sub

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top