Reply

How to extract data from a .asm file

Hi guys,

 

I'm totally new to Solid Edge and its API but I do have experience in programming (java, vb, c++).  

 

I'm looking for a way to extract (via script/API but not manually) the information from a .asm and/or .par document.

 

In other words, I'd like to choose a .asm file and to be able to extract (into an xml file as instance) the information about this assembly and its content.  And if the assembly contains sub-assemblies, then to perform the same recursive algorithm in order to get to all parts.  

 

I want to be able to display the assembly tree like this (with all the informations (part#, qty, description, ...)):

-ASM1

      - PART1

      - PART2

      - SUB_ASM1

            - PART3

            - PART4

      - SUB_ASM2

            - PART5

      -PART6

 

I guess I'm not the first one that needs to do such a thing.  What would be the best way to do so according to you?  From the research I did, RevisionManager API could be the solution...

 

Thank you very much.

10 REPLIES

Re: How to extract data from a .asm file

Continuing from your previous reply in the SE forum:

======================================================

Thank's a lot for your answer, I thinkI get it.

 

Just one little thing, when you do this:

    Set oApp = GetObject(, "SolidEdge.Application")
    Set oDoc = oApp.ActiveDocument

 

Is SolidEdge opened? I guess it is, otherwise, what would ActiveDocument refer to...

 

But if I don't want SolidEdge to be opened?  Let's say, I have a folder with all my .asm and .par and I wanna loop into all of them (like a batch script)?

 

How would I open the document?  Is there a method like this?

    Set oDoc = oApp.GetDocument("c:\SolidEdge\assembly1234.asm")

 

Thank's.

======================================================

 

I assume you are using .Net, especialy VB.Net.

You should use this statement at the top:

 

Imports System.Runtime.Interopservices

 

From this namespace, use the Marshal class' GetActiveObject method:

 

oApp = Marshal.GetActiveObject("SolidEdge,Application")

 

For the active document, use:

 

Dim oDocs as SolidEdgeFramework.Documents

oDoc = oDocs.Open("c:\SolidEdge\assembly1234.asm")

 

A series of basic Solid Edge programming tutorials are on this site:

www.SurfAndCode.in

 

Re: How to extract data from a .asm file

To loop into all Solid Edge files from a folder, pls have a look at this open source project where this is implemented

 

There's both the full source code and also an indepth tutorial on how to use the code and what each line in the code means:

 

Hope you find your answers.

BR,

Tushar Suradkar

www.SurfAndCode.in

 

Re: How to extract data from a .asm file

Hey Rick. Welcome to the community.

 

I would first like to clear up exactly what you're after. Are you after the actual BOM or just the structure? I ask because depending on your answer, the solution will vary.

 

You can find code samples at SolidEdgeCommunity / Samples repository on GitHub. There are BOM and structure samples in C++, C# & Visual Basic. If you look at line 71 of the C++ BOM sample, you will see where an Occurrence has an IncludeInBom property that I'm checking for. The user can configure this via the Solid Edge GUI and standard Solid Edge reports respect that setting.

 

The following samples demonstrate the Solid Edge API. The RevisionManager API can do structure stuff but not true BOM.

 

BOM

C++ BOM sample

C# ExtractBOM sample

C# BOM samle

Visual Basic ExtractBOM sample

Visual Basic BOM sample

 

Structure

C# ExtractStructure sample

Visual Basic ExtractStructure sample

 

I don't have any RevisionManager samples on GitHub at the moment but you can likely find samples here in the forums if you search.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How to extract data from a .asm file

Thank you for all previous answers.

 

I'm not an engineer and I'm not really familiar with BOMs.  What is the difference between what I asked for (a detailed tree structure of an assembly) and a BOM?  I thought it was pretty similar...

 

Thank's again.

Re: How to extract data from a .asm file

I believe there is a lightweight utility to do this type of thing called "SEReader.dll" located in the SDK section of the Solid Edge install folders.  You can combine with PropAuto.dll to get to properties.

 

From the accompanying Word file...

 

User’s Guide to the SEReader API

This dll enables access to a SE asm files without the requirement for having Solid Edge loaded on the local system.

 

Run regsvr32 on the SEReader.dll and look at the objects and interfaces in the typelib (the lib is in the dll). The top level object allows you to open one asm file at a time, get the attachments object and then enumerate each part occurrence. The occurrence object returns three pieces of information, the matrix, the range and the filename. You can use the name to keep track of the count.


Thanks,
Ken

Production: ST9 MP7
Testing: ST10

Re: How to extract data from a .asm file

I'm not an engineer either ;-)

 

Off the top of my head, a BOM will tell you how many times a particular part is used. For example. bolt.par may be used 10 times in an assembly. If you're just looking at the structure (linked documents in RevisionManager), you'll only know that bolt.par is referenced. I also mentioned that an SolidEdgeFramework.Occurrence has an IncludeInBOM property that you must (should) respect if producing a BOM.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How to extract data from a .asm file

Ok, then what I need is the BOM.

 

I thought I was clear in my first post that I needed the qty of occurences of each parts and sub-asemblies...

 

So to resume, which API I must use? 

 

Thank's

Re: How to extract data from a .asm file

The Solid Edge API. See my ExtractBOM sample for an example.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How to extract data from a .asm file

We have the need to extract the bill of material information for an assembly and all sub assemblies for import into mrp system.  We also intend to import new parts inormation as well. I am interested in using the sereader.dll from the sdk for this purpose. Has anyone had success with using this for this purpose and without the requirement of having solid edge installed on the machine?