×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Querying for a List of Electrical Objects

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.

RE: Querying for a List of Electrical Objects

Hello,
What do you use to access those objects? Can you post your code plz?

RE: Querying for a List of Electrical Objects

(OP)
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

RE: Querying for a List of Electrical Objects

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 --> CATScript

Sub CATMain()
Msgbox Typename(CATIA.Activedocument.Selection.Item2(1).Value)
End Sub 

Regards

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources