CATIA links

Eric Neuville

CATIA links

hello,

 I have a link question:

 How can I check links from CATIA file? I am looking for the information I have from the menu edit / links...

 CATProduct to element within the CATProduct, that's easy, I check the Products family

CATPart to CATPart (created from copy paste as result with link) : do I have to check all geometrical element, and what do I look for?

CATDrawing (generative view) is easy with GenerativeViewLinks.

CATDrawing to CATDrawing (copy a view with local ditto, the pasted view is linked with file where the copy was done) : Where do I find this link?

 

I also wonder if any of those can be retrieved with KWA/KWE or KD3

 

Thanks for your help

Little Cthulhu

RE: CATIA links
(in response to Eric Neuville)
Hi.
Links are PITA both in Automation and KW. I have just implemented link analysis tool for my application and I used WinAPI to read contents of tha "Links of ..." window

Eric Neuville

RE: CATIA links
(in response to Little Cthulhu)

Good to hear from you... I wish you could find some time to call me monday, I would like to talk to you and I've been unlucky to find who is behind the famous Little Cthulhu on the forum and I cannot find your pseudo on UTC phone book. :)

Edited By:
Eric Neuville[Pratt & Whitney Canada*] @ Oct 12, 2012 - 06:17 PM (America/Eastern)

Little Cthulhu

RE: CATIA links
(in response to Eric Neuville)
Sure, Eric, I always look forward to share experience with other CATIA automation experts.
Feel free to e-mail me at gmail. I use catiafidelity account there.

Gerardo Veredas

RE: CATIA links
(in response to Little Cthulhu)



In Reply to Little Cthulhu:

Hi.
Links are PITA both in Automation and KW. I have just implemented link analysis tool for my application and I used WinAPI to read contents of tha "Links of ..." window

Hi, I am currently implementing exactly the same kind of tool and saw your comment on this thread!

As you say, is is a hell to read the Edit>Links window, even through API.

I've now been stuck for weeks with the problem of reading the ListView32 object (the list where the all the Links info is displayed). As you well know, it is ownerdrawn, so one cannot simply read its contents. I tried the usual method of reserving memory for a LV_ITEM in the CATIA process, sending a LVM_GETITEM message and reading it back, and I keep getting only empty strings (I tried a many variations, no results).

I've tried every Spy++-like program you can imagine, including Spy++, Diversify, WinSpy, SysExporter,... nothing works. I tried to monitor the messages sent to the process using Spy++, nothing.

I could find the Links data by searching the entire (!!!) CATIA process memory. It seems that the actual data are stored somewhere in memory and drawn on the list every time the user interacts with it, while the list itself is filled with empty data.

If you could give me any hint on how to read these Links data, I would really, really, appreciate. As I said, I am now completely stuck, and the only viable option for me now seems to pass through reading the entire memory. I would like to avoid this if there is some obvious solution I've been stupidly missing!

I am using VBA and have no possibility to access VS in my company :'(

Many thanks!!

Eric Neuville

RE: CATIA links
(in response to Gerardo Veredas)

it's not going to help you but we got the link info using CAA.

Wish I could help you more.

Gerardo Veredas

RE: CATIA links
(in response to Eric Neuville)

Thanks, but I don't have access to CAA either, so VBA and API are my only possibilities...

I mean, API in this case should be more than enough. But, c'mon, hiding data in memory and manually drawing it in the class to prevent external apps from reading it?? That's a clear intention against developers (ok, not real developers, just VBA ;) )

Jon Houghton

RE: CATIA links
(in response to Gerardo Veredas)

Gerardo,

I suggest taking a look a the lesser known UIAutomation API. I ran into the same problem as you with x64 systems and I spent a long time trying to get it to work before finding success with UIAutomation. I had to actually read the links and then relink references using computer vision/object recognition and simulating mouseclicks for the owner drawn graphical relinking windows.

Beware that sometimes the InvokePattern.Invoke() doesn't work for some controls. Occasionally I had to use WINApi for clicking. You should be able to figure out the API pretty quickly based on the MSDN examples.

Hope this helps.

Edit: Oh, and also get Inspect.exe or UISpy.exe which are the Spy++ equivalents for UIAutomation.

- Jon

Attachments

  • WindowReaderDemo.mp4 (4413.3k)
Edited By:
Jon H[Pacifica-Engineering Inc] @ Nov 11, 2015 - 11:51 AM (America/Pacific)

Little Cthulhu

RE: CATIA links
(in response to Eric Neuville)



In Reply to Eric Neuville:

it's not going to help you but we got the link info using CAA.

Wish I could help you more.

What CAA interfaces do you use?

Little Cthulhu

RE: CATIA links
(in response to Gerardo Veredas)



In Reply to Gerardo Veredas:

I've now been stuck for weeks with the problem of reading the ListView32 object (the list where the all the Links info is displayed). As you well know, it is ownerdrawn, so one cannot simply read its contents. I tried the usual method of reserving memory for a LV_ITEM in the CATIA process, sending a LVM_GETITEM message and reading it back, and I keep getting only empty strings (I tried a many variations, no results).

Hi.

To get info about currently displayed items you use LVITEM structure. And it works well as long as this structure (as well as your code) resides in the same process where listview is displayed, i.e. CNEXT.exe. But in some (or even all?) x64 releases of CATIA VBA macros are hosted by a standalone process named CATVBAHostingApplication.exe, so when you allocate memory for LVITEM and send LVM_GETITEM message to CATIA it may not be able to access created LVITEM.

What you need to do is to allocate LVITEM in CATIA's memory space with WriteProcessMemory, send LVM_GETITEM message and read results back with ReadProcessMemory. See stackoverflow for samples.

Xavier Klein

RE: CATIA links
(in response to Little Cthulhu)

Hello,

About CATIA links (access to the list display in Edit Links)

a very efficient way to get it is to use

    Set CATIA = GetObject(, "CATIA.Application") 
    Dim oStiEngine ' As StiEngine
    Set oStiEngine = CATIA.GetItem("CAIEngine")
    Dim oStiDBItem ' As StiDBItem
    Set oStiDBItem = oStiEngine.GetStiDBItemFromAnyObject(CATIA.ActiveDocument)

see thread  http://www.coe.org/p/fo/et/thread=28292

The only Links that I am not able to retreive is Excel File insert in a CATDrawing

(but this links is display nowhere)

to improve performance (reduce Memory usage) , it is better to use option "Do not load Reference docuùent"  

(see CATCafGeneralSessionSettingCtrl   http://www.coe.org/p/fo/et/thread=18521 )

 

Gerardo Veredas

RE: CATIA links
(in response to Little Cthulhu)

In Reply to Little Cthulhu:

Hi.

To get info about currently displayed items you use LVITEM structure. And it works well as long as this structure (as well as your code) resides in the same process where listview is displayed, i.e. CNEXT.exe. But in some (or even all?) x64 releases of CATIA VBA macros are hosted by a standalone process named CATVBAHostingApplication.exe, so when you allocate memory for LVITEM and send LVM_GETITEM message to CATIA it may not be able to access created LVITEM.

What you need to do is to allocate LVITEM in CATIA's memory space with WriteProcessMemory, send LVM_GETITEM message and read results back with ReadProcessMemory. See stackoverflow for samples.

 

Hi,

I already tried that, with no results. I'm actually running the macro from Excel VBA. Here are the steps I'm following:

  • First, open a handle, with read/write permissions, to the CATIA process
  • Then, allocate memory in the CATIA process for both, the LVITEM and the LVITEMTEXT structures, with ok result
  • Initialize the LV_ITEM (tried many variations here)
  • Write both structures LVITEM and LVITEMTEX in the process memory, with ok result. At this point, I read the memory address with Process Hacker and yes, the structure with the data has been written and is in CATIA memory.
  • Send the LVM_GETITEM message, with ok result. But nothing has been written at the memory address.
  • Read the both LVITEM and LVITEMTEX memory addresses, with ok result.
  • I get only empty strings, ocassionally a single Chr(1) character.

I've tried many variations of this method. Using only the LVITEM, initializing it with many different options... nothing

I've also tried to send other messages, like LVM_SETITEMSTATE to select items, with good results. I can also access the other elements of the Edit>Links window, like the comboboxes, labels, even the dummy buttons.

How did you do in your app? Might it be that the LVITEM must be written in the Edit>Links thread private memory, not just CATIA process memory? Just guessing

Gerardo Veredas

RE: CATIA links
(in response to Xavier Klein)



In Reply to Xavier Klein:

Hello,

About CATIA links (access to the list display in Edit Links)

a very efficient way to get it is to use

    Set CATIA = GetObject(, "CATIA.Application") 
    Dim oStiEngine ' As StiEngine
    Set oStiEngine = CATIA.GetItem("CAIEngine")
    Dim oStiDBItem ' As StiDBItem
    Set oStiDBItem = oStiEngine.GetStiDBItemFromAnyObject(CATIA.ActiveDocument)

see thread  http://www.coe.org/p/fo/et/thread=28292

The only Links that I am not able to retreive is Excel File insert in a CATDrawing

(but this links is display nowhere)

to improve performance (reduce Memory usage) , it is better to use option "Do not load Reference docuùent"  

(see CATCafGeneralSessionSettingCtrl   http://www.coe.org/p/fo/et/thread=18521 )

 

 

Hi,

This method works perfectly! Thanks!

I will switch to it and forget about API. It's much faster. It's also detecting CCP links, which interest me.

Thank you again for this good solution!