Cancel
Showing results for 
Search instead for 
Did you mean: 

Custom feature for prims, pyramids and truncated pyramids

I have created a custom feature  that handles prisms, pyramids and truncated pyramids for 3 to 8 base edges. I have signed the required UI and Core program files but also included the vb source code. I have tested the programs using NX11, NX12 and NX 1847.

 

Interested in feedback regarding any suggested changes/improvements.

 

Frank Swinkels

8 REPLIES 8

Re: Custom feature for prims, pyramids and truncated pyramids

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Thanks for sharing this but I was not able to get the desired results yet and below are some findings.

 

- Never saw a pyramid but received an error "NXException: The specified string contains a syntax error".

It might be caused by non-matching locale/culture setting on value/string conversion for expressions.

This output should provide more than the pure exception message string (use ex.ToString also in the callbacks)

- The Custom Feature should provide a custom bitmap to be displayed in the part navigator.

- There is no error checking for invalid inputs.

- Minor typo

 

See attached screenshot.

Re: Custom feature for prims, pyramids and truncated pyramids

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

To avoid number parsing problems use the following two lines to force English regional settings.

        Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
        Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")

Hope this helps.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.2, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Re: Custom feature for prims, pyramids and truncated pyramids

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

@Stefan_Pendl wrote:

To avoid number parsing problems use the following two lines to force English regional settings.

        Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
        Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")

 

Yes, or create a NumberFormatInfo object and set some of its properties only:

 

Dim format As Globalization.NumberFormatInfo = New Globalization.NumberFormatInfo()
format.NumberDecimalSeparator = "."
Dim x As Double = 100
Dim y As Double = 3
Dim z As Double = x / y
Dim expStr As String = z.ToString(format)

Re: Custom feature for prims, pyramids and truncated pyramids

Thanks all for looking at this.

 

1. I corrected the spelling error for truncated pyramid.

 

2. I have included the bitmap in the updated package (I used SquarePyramid.bmp)

 

3. I believe it is unnecessary to error check that truncated height is less than or equal to pyramid apex height. No error occurs say a user sets the truncated height to 100.0 and the pyramid height to 50.0 then the truncated pyramid option simply creates a pyramid.  I did add minimum of 0.05 and maximum of 1000.0 so that negative numbers or very large number are caught.

 

4. I had built the dlls for NX11.  All runs fine using NX11. I was not careful enough when I did my testing using NX12 so yes the error occurs when running the NX11 verion on NX12.  I have now compiled and signed a NX12 only version.  I believe it runs fine using NX12 and NX.

 

Attached is the updated package.

 

Frank Swinkels

Re: Custom feature for prims, pyramids and truncated pyramids

Siemens Genius Siemens Genius
Siemens Genius

Hi Frank,

 

Below are comments to make this more like native features in NX.

 

Specify Csys UI Block SmartUpdateOption must be withinModeling (you will get curcular update sometime or later otherwise.)

 

Number of edges UI block should be expression and corresponding customAttribute should be of expression type (Integer) - This allows user to edit value from Details window by selecting feature in navigator

 

Base Defined by should control Visibility of corrsponding required input (Base Edge Length, Base Inscribed Radius, Base Circumscribed Radius) as not all input are needed all the time.

 

Also Base Edge Length, Base Inscribed Radius, Base Circumscribed Radius should use expression block (length type) and corresponding CustomAttribute should be of type Expression - This allows user to edit value from Details window by selecting feature in navigator

 

Prisma/Pyramid Apex Height and Truncated Height should use expression block (length type) and corresponding CustomAttribute should be of type Expression - This allows user to edit value from Details window by selecting feature in navigator

 

Using expressions will remove the problem of localization.

 

Did not look into core file yet.

 

These examples really helps new users in long way to devevlop new custom features.

 

Thanks,

Shriganesh

SE-Advanced
Siemens Industry Software

Re: Custom feature for prims, pyramids and truncated pyramids

Hi Shriganesh,

 

Thanks for the input.

 

Taking the easy suggestions first I see no difficulty with changing the prism/pyramid apex length to expressions.  For interest I will certainly do this.

 

Thinking about the number of edges.  Now this must be limited to >= 3 and <= 8. This is simple to implement with the dialog but to my knowledge not as easy with expressions? Maybe someone can suggest a way of doing this.

 

Now assuming I have a usable expression for number of edges then thinking about the relationship between edge length, insribed radius and circumscribed radius what I did was to only save the edge length as a custom attribute.  When a uses enters say a circumscribed radius then the edge length is calculated and the edge length is saved as the custom attribute.  So thinking again about expressions having the edge length as an expression is simple and OK but a circumscribed radius or inscribed radius can not be user expressions.  To have edge length, circumscribed radius and inscribed radius as custom attributes is not possible (as you sugest this would be circular references).  I am interested on your thoughts on this.

 

Finally I dont think there was ever a localization problem.  It was a problem of compiling using NX11 libraries and running it on NX12.

 

Thakn again for the input and look forward to further comments.

 

Frank Swinkels

Re: Custom feature for prims, pyramids and truncated pyramids

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

 


@FrankSwinks1 wrote:

Finally I dont think there was ever a localization problem.  It was a problem of compiling using NX11 libraries and running it on NX12.


It really depends on the Windows Region / Keyboard setting.

 

Public Sub EditExtrusion3(ByVal theAngle As Double, ByVal pyramidHeight1 As Double, ByVal csys1 As CartesianCoordinateSystem,
                               ByRef theExtrude As Extrude)
        Dim extrudeBuilder1 As NXOpen.Features.ExtrudeBuilder = wp.Features.CreateExtrudeBuilder(theExtrude)

        extrudeBuilder1.Draft.DraftOption = NXOpen.GeometricUtilities.SimpleDraft.SimpleDraftType.SimpleFromStart
        extrudeBuilder1.Draft.FrontDraftAngle.RightHandSide = theAngle.ToString
etc.

 

With a German Keyboard Layout, theAngle.ToString returns the value "26.565051177078" as "26,565051177078":

 

The specified string contains a syntax error
Syntax error here
(Number [degrees]) p154: 26,
Unhandled exception encountered in callback automation code.

 

One of the earlier mentioned Culture / Format suggestions solves this issue but I would go with Shriganesh's suggestion to use Expression blocks (as demonstrated in the other samples).

 

Re: Custom feature for prims, pyramids and truncated pyramids

Thanks again for this.  I have never had to deal with the issue of number format ",".  Attached is the updated NX12 version.  I am interested in being able to use expressions and will be looking at this.  The interesting problem is that, for example, looking at the pyramid angle it is calculated from

InscribedRadius = BaseEdgeLength/(2*Tan(PI/EdgeNumber)

and

PyramidAngle=Atan(InscribedRadius/PyramidHeight)*180/PI

So an expression for the pyramid angle would be a function of an expression for the inscribed radius (which is a function of base edge length and edge number) and the expression for pyramid height.

 

I am certainly going to look at this.

 

Frank Swinkels