cancel
Showing results for 
Search instead for 
Did you mean: 

code snippet visual basic

Pioneer
Pioneer

Hello all,

I'm new to programming in visual basic for NX.

I'm trying to create a dll to execute some recursive operation on a CAD with NXOpen.

In particular, I need to measure the surface of  some specific objects/ features and the volume.

 

If I am not in wrong to select a feature I have to write:

 

Dim sphere1 As Features.Sphere = CType(workPart.Features.FindObject("SPHERE(9)"), Features.Sphere)

 

now I cannot find the command to measure the area of the faces and the volume.

 

After, I also need to measure area and volume of the faces of a boolean feature.

 

Thanks a lot for you help

 

Luigi

19 REPLIES

Re: code snippet visual basic

Pioneer
Pioneer

Hello all, please help me!

Re: code snippet visual basic

Honored Contributor
Honored Contributor

Do you want to create an associative measure feature (volume, surface area, etc), or do you just need the values for use within the journal?

Re: code snippet visual basic

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Luigi,

 

We hava a lot of NXOpen code samples available in the Solution Center.  I have attached one that should be a good starting point for you.

 

Regards,

 

Steve

 

Re: code snippet visual basic

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Luigi,

 

Please ignore the first one and try this one instead.  This allows you to select a Body object, instead of selecting a Tag and then converting it to a Body.  (Just a little cleaner...)

 

Regards,

 

Steve

 

Re: code snippet visual basic

Pioneer
Pioneer
Thanks a lot for the examples...I can try it on monday at the office.
For cowski: I need the value to use it inside the VB code and to write it in an external txt file with others measures.
Sorry Steve, where I can find others example?
Sorry for my unknowledge but I am starting to learn right now and I didn't find a manual.

Thanks a lot forma your help

Re: code snippet visual basic

Siemens Phenom Siemens Phenom
Siemens Phenom

You said you can't find any manuals. I suggest you solve that problem, first. The NX API documentation doesn't get installed, by default, so you may have to go get it installed.

 

If you're new to programming, you might find it helpful to read the "Getting Started with SNAP' guide, for starters, even if you don't use SNAP. It's part of the standard NX documentation set.

 

To measure area, there is a Snap.Compute.MassProperties function that will give you the surface area of a body, and a Snap.NX.Face.Area property. In the NX/Open library, there is  NXOpen.UF.UFModl.AskMassProps3d.

山田
yamada

Re: code snippet visual basic

Pioneer
Pioneer

Hi Yamada,

thanks for your reply.

I already installed the NX API documentation but it's not clear as the SNAP documetation.

 

I read also the "Getting Started with SNAP" that helped me to start with some first operations but we don't have SNAP license so I cannot use SNAP commands.

 

It would be usefull to find a "Getting started with NXOpen".

 

Furthermore, for me at least, it's not so simple to use the NX API documentation.

 

Luigi

Re: code snippet visual basic

Pioneer
Pioneer

Hi cowski,

thanks a lot for your reply.

I need the value to use it inside the VB code and to write it in an external .txt file with other measures.

 

thanks in advance

 

Luigi

Re: code snippet visual basic

Pioneer
Pioneer

Hi Steve, thanks a lot for the examples.

 

I modified the code to get a specific named body, because I don't need of the interactive selection:

 

Dim Intersezione As Body = CType(workPart.Bodies.FindObject("INTERSECT(11)"), Body)

 

1) Now I cannot get the area measurement of a specific feature.

To be more clear, I need to get the area of "Intersect(11)" but I also need to get the area of a Sphere Feature.

 

2) How can I select a body with a customized name?

 

Thanks in advance

 

Luigi