Cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating between NX and Excel

Siemens Phenom Siemens Phenom
Siemens Phenom

I wrote this document a few years ago, but never got around to adding it to the SNAP or NX/Open docs. There are often questions here about exchanging data with Excel, so I thought it might be useful to people.

 

I'm certainly not an expert on Excel, so other people may know better ways to do this stuff. If so, please add comments/corrections.

山田
yamada
5 REPLIES 5

Re: Communicating between NX and Excel

Phenom
Phenom

Very good document Yamada. Thanks for sharing it. I don't use snap l myself (no licence) but still very usefule. A possible suggestion. In section 'Importing From Excel' might be worth adding xls related "constants" so that anyone familliar with excel programming might recognise them. Things like;

Const xlDown As Long = -4121
Const xlUp As Long = -4162
Const xlToRight As Long = -4161
Const xlMultiply As Long = 4
Const xlPasteAll As Long = -4104

which is usefule to loop through a range. In your example the range is fixed

 

Just a thought...

 

 

 

Production: NX.CAE 10.0.2.6
Development: VB.NET (amateur level !)

Re: Communicating between NX and Excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@selex_ct wrote:

Very good document Yamada. Thanks for sharing it. I don't use snap l myself (no licence) but still very usefule. A possible suggestion. In section 'Importing From Excel' might be worth adding xls related "constants" so that anyone familliar with excel programming might recognise them. Things like;

Const xlDown As Long = -4121
Const xlUp As Long = -4162
Const xlToRight As Long = -4161
Const xlMultiply As Long = 4
Const xlPasteAll As Long = -4104

which is usefule to loop through a range. In your example the range is fixed

 

Just a thought...

 

 

 


If you have a .net author license, you can add a reference to the Excel API (as shown in the document); in this case, you don't need to define your own "Excel" constants, you can access them directly through the Excel API. You only need to define your own constants if you are using "plain vanilla" journals (which don't let you add a reference to the Excel library).

Re: Communicating between NX and Excel

Phenom
Phenom

Ok. Noted. Thanks for that. I am limited (mainly by my programming knowledge!) in terms of "proper" programming because I am not allowed (for security reason) to compile my small programmes. So in effect I run "flavoured vanilla" journals. It does work so still happy with it. I will however looked in to the Excel API (as shown in the document).

Production: NX.CAE 10.0.2.6
Development: VB.NET (amateur level !)

Re: Communicating between NX and Excel

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi, Yamada san,

Not sure if this post is relevant to the main thread. But just wanted to know if it is possible to automate the update of NX part once excel is updated.

I have an excel file and my NX part reads data from the excel. When I do editing in the excel and save it I need to use Update for External Change to update my NX part. Is there a way I can get past this update for external change step?

At least I am not aware of any such thing.

 

Thanks and Best Regards

Kapil

Re: Communicating between NX and Excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@kapilsharma wrote:

Hi, Yamada san,

Not sure if this post is relevant to the main thread. But just wanted to know if it is possible to automate the update of NX part once excel is updated.

I have an excel file and my NX part reads data from the excel. When I do editing in the excel and save it I need to use Update for External Change to update my NX part. Is there a way I can get past this update for external change step?

At least I am not aware of any such thing.

 

Thanks and Best Regards

Kapil


Refer to the GTAC solution center example nx_api5457 or nx_api5455.

 

There is no NXOpen API method to perform the same thing as the interactive option Tools-> Update-> Update for External Change.  See ERs 6888643, 6771744, 2069181, 2175218, 6872272.

This example demonstrates using the Knowledge Fusion function %ug_updateForExternalChange to make that happen.

    static void UpdateForExternalChange()
    {
        string ruleName;
        theUFSession.Cfi.GetUniqueFilename(out ruleName);
        workPart.RuleManager.CreateDynamicRule("root:", ruleName,
            "Any", "%ug_updateForExternalChange(false)", "");
        workPart.RuleManager.Evaluate(ruleName + ":");
        workPart.RuleManager.DeleteDynamicRule("root:", ruleName);
    }