Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SNAP - Beginner user, SNAP tool, Problems with guide 1

Status
Not open for further replies.

Frank2288

Mechanical
Nov 20, 2015
38
Hi, i am a new user of the forum.

I am currently planning an activity on siemens NX that involves the design of a tool with new reverse engineering features within NX.

I am oriented towards the use of SNAP to build this tool, and i started reading the guide for beginners, but i also need to determine if SNAP offers access to all the functionalities of NX that i need (e.g. deviation between CAD/faceted model). To do this i am trying to use the complete guide, but that doesn't seem to work properly. (I see the list of classes and methods but not the description and the "help")

Does anyone have the same problems with the guide?
I am looking for a complete guide to SNAP but i can't find it.

Can you help me?

Thanks.
 
Replies continue below

Recommended for you

You need to (or have the IT administrator to) install the full version of help document with NX.

 
Failure to display the content in the right-hand pane is a result of some Windows security nonsense. The SNAP Reference Guide is a CHM file, and these make Windows nervous, so it blocks the content. I forget exactly how to fix this, offhand, but you can probably find the solution by searching. It's a general problem with CHM files; it's not specific to SNAP.

Try this:
If you're writing a big sophisticated application, then SNAP may not have enough functionality by itself. You may have to use some NX/Open functions, in addition. This is OK -- there is no problem mixing calls to SNAP functions and calls to NX/Open functions in your program. The SNAP functions are far better documented and easier to use, of course, so best to use those where they do the job, and fall back to NX/Open functions only where necessary.

SNAP has some Deviation Checking functions, but they don't handle facetted models.
 
Failure to display the content in the right-hand pane is a result of some Windows security nonsense. The SNAP Reference Guide is a CHM file, and these make Windows nervous, so it blocks the content. I forget exactly how to fix this, offhand, but you can probably find the solution by searching. It's a general problem with CHM files; it's not specific to SNAP.

Try this:
If you're writing a big sophisticated application, then SNAP may not have enough functionality by itself. You may have to use some NX/Open functions, in addition. This is OK -- there is no problem mixing calls to SNAP functions and calls to NX/Open functions in your program. The SNAP functions are far better documented and easier to use, of course, so best to use those where they do the job, and fall back to NX/Open functions only where necessary.

SNAP has some Deviation Checking functions, but they don't handle facetted models.

Thanks, i'll try this.

Regarding the NX/Open and Snap, i think i've read somewhere that is possible to start a SNAP project and then appeal to NX Open to make up for SNAP limits without problems, is it right?

I am very interested in your last sentence.. I saw Deviation functions in the list of functions, and i thought that the whole "reverse engineering" package of functions was accessible via SNAP. What do you mean with "don't handle facetted models"?

Thanks.

@xwang11 - In theory i have the full documentation installed.
 
Little update regarding the guide: i tried a couple of solutions from your link, and now i can see the full guide! Thanks for that!
 
> possible to start a SNAP project and then appeal to NX Open to make up for SNAP limits without problems, is it right?

That's roughly correct. But you're not looking at it quite right.

The things you are creating are just VB programs. A VB program can call any function in any .NET library. Two of the available libraries are SNAP and NX/Open. There are thousands of other libraries, too, of course.

So, again, I suggest you call the SNAP functions where they do the job, and fall back to NX/Open functions where necessary.

When you start a SNAP project, it doesn't do anything magic. It just sets up some references to various libraries. You could easily set up these references yourself, if you wanted. There's an example in the SNAP Getting Started guide that shows you how. If you want to call both SNAP functions and NXOpen functions, then your project has to include references to both of these libraries.

> i thought that the whole "reverse engineering" package of functions was accessible via SNAP

No. Not even close. Use the NX/Open functions for checking deviation between facetted objects and surfaces.

Glad the documentation is working for you.



 
Thank you for your help.

Just to clarify the last point: does NX/Open offers functions that covers every NX tool?

Thanks again, your information was precious.
 
> does NX/Open offers functions that covers every NX tool?

No, but the coverage is pretty broad. For each new function in the user interface, there is an NX/Open function that does the same thing. However, functions that mimic the UI are not always the best design for programmatic use, so there are problems, sometimes. Also, the documentation is often poor; that's where SNAP helps.
 
Hi!
I resume this thread to ask you a couple of things. Thanks again for your answers!

I am testing SNAP and improving my Visual Basic skills.

I was trying to use SNAP to build a program to extrude a rectangle, to test some functions and my comprehension of VB. I wrote this:

Code:
Imports Snap, Snap.Create

Public Class MyProgram

    Public Shared Sub Main()

        Dim istructions As String()
        Dim labels As String()
        Dim values_1 As Double()
        Dim results As Double()

        istructions = {"Enter a value for a - mm", "enter a value for b - mm"}
        labels = {"a", "b"}
        values_1 = {100, 40}

        'Open a window to get input from user - stored in "results" 
        results = Snap.UI.Input.GetDoubles("Sketch definition", istructions, values_1)

        Dim center As Position
        center = {0, 0, 0}


        Dim draw_rectangle As NX.Line()
        draw_rectangle = Rectangle(center, results(0), results(1))

        Dim vector_Z As Vector
        vector_Z = {0, 0, 1}

        Dim prism As NX.Extrude

        prism = Extrude(draw_rectangle, vector_Z, 200)

    End Sub

End Class

A couple of questions:
1) If you have any advice about errors or things that i should do different, please tell me.
2) I noticed that using this code, in NX there is no mention of sketches. The rectangle is extruded correctly, but in the history tree there is no sketch that i can modify later. How can i solve this issue? What steps i need to follow to create a sketch? Is it possible using SNAP? I tried to record my actions with the journal and this simple model (create a sketch --> draw a rectangle --> extrude it) created 10 pages of code in VB.

Thanks!
 
Your are correct in saying that the Snap Rectangle command doesn't create a Sketch. It just creates four lines. You can edit these lines, but not using sketch-based techniques.

If you want to create a sketch, you have to use NX/Open functions. Create a SketchBuilder, populate it, and Commit it. Then Activate it, and call AddGeometry to add curves to it.

On a different topic, your VB code is a bit old-fashioned looking. Nowadays, people don't write declarations separate from the rest of the code -- you declare things as you need them. And, if you use "Option Infer On", then you don't really need declarations, most of the time. Here is a more modern (and shorter) version of your code:

Code:
Option Infer On
Imports Snap, Snap.Create

Public Class MyProgram

    Public Shared Sub Main()

        Dim istructions = {"Enter a value for a - mm", "enter a value for b - mm"}
        Dim labels = {"a", "b"}
        Dim values As Double() = {100, 40}

        'Open a window to get input from user - stored in "results" 
        Dim results = Snap.UI.Input.GetDoubles("Sketch definition", istructions, values)

        Dim rect As NX.Line() = Rectangle(Position.Origin, results(0), results(1))

        Dim prism = Extrude(rect, Vector.AxisZ, 200)

    End Sub

End Class
 
Thanks!

I'll try to use SNAP where possible, and if i can't make without sketches i'll try OPEN.


Regarding my code: i'm learning VB. This is my first time working on it. I read on the guide about the possibility of omitting declarations, but i thought that in these first applications a full-declaration would have helped me in making less mistakes.


On another topic: i tried to use the "record" option of the journal to use some of the code that creates. Is this a good strategy? Are there any precautions i need to take?

Thanks again.
 
> a full-declaration would have helped me in making less mistakes.

Well, declarations help the complier find mistakes for you, so they're good. But this doesn't mean that you should put them on a separate line, all by themselves. And it definitely doesn't mean you should put them all together at the start of your program. My personal strategy is to use "Option Infer On", which means that a declaration is essentially just putting "Dim" at the start of the appropriate lines of code. I write "Dim x as Something" only when the "Something" is not clear from the context.

> use the "record" option ... Is this a good strategy?
It's sometimes a good way to find the functions you need. But, personally, I think the generated code is pretty horrible, and I generally throw most of it away after reading it.

> Are there any precautions i need to take?
There are two that spring to mind.
(1) Don't get confused by the "FindObject" calls that occur in journals. Read the section in the SNAP Manual that tells you how to get rid of them.
(2) Don't copy the coding style of recorded journals; it's not very good, in my opinion. But, since the code was written by a computer, perhaps we can't expect it to be very good. You are human. You can do better.

 
Thanks for your help!

On another topic: i need to write a segment of code that to allow the user to select a facet body and a surface of a body and perform operations (like deviation analysis) between the two. Could you give me a help to start the code? What is the most convenient way to perform the selection?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor