Querying for a List of Electrical Objects
Querying for a List of Electrical Objects
(OP)
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.
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.





RE: Querying for a List of Electrical Objects
What do you use to access those objects? Can you post your code plz?
RE: Querying for a List of Electrical Objects
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
RE: Querying for a List of Electrical Objects
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 --> CATScript
Regards