Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Using a Journal to organize the file

Status
Not open for further replies.

wiengines

Mechanical
Nov 10, 2008
59
Using NX6...

I am attempting to write a journal that will organize my file, mainly to place things on different layers so that the file conforms to our standards.

To start, I thought I would tackle moving each sketch to it's own unique layer. I was able to do this, but I discovered that it is looking at each layer in the order that they were created, NOT in the order that they are in the model tree, which is what I prefer.

Any ideas?

Chris T.
Project Design Analyst
Kohler Co. Engine Division
Using NX6
 
Replies continue below

Recommended for you

wiengines said:
it is looking at each layer in the order that they were created, NOT in the order that they are in the model tree

ummm, what?

I assume you meant "each sketch in the order they were created" but even so, to see how that is relevant you'll need to give more information.

Why must the sketches be presented in timestamp order, is the user verifying each one (interactively while the journal is running)? What layer(s) do you want the sketches on?

www.nxjournaling.com
 
Cowski,

Yes, I meant "each sketch ..." It's been a long week [mad]

I suppose I was a little vague in my original post, so hear is some more details.

Our standards state following:
That each sketch must be on thier own unique layer.
The layers we have reserved are 101-200.
As you progress down the model tree, the layers that each sketch is on should not jump around.

My end goal for this program is for the program to find each sketch, in timestamp order, and place them on thier own unique layer; starting with layer 101, without any user interaction.

The code I have written so far works great except for two intances:
1) If the sketches have been re-ordered in the model tree.
2) If the user makes a feature the current feature, creates a new sketch; and then continues on from there.

In both of those instances (which happen alot), the creation timestamp is different than the timestamp of the model tree, and that is my issue.

Having said all of that, I do feel that our stanards are a little overkill...but since I have bigger issues to deal with I would love to find a way to make it as painless as possible!

Chris T.
Project Design Analyst
Kohler Co. Engine Division
Using NX6
 
Here is my code so far...

Code:
Option Strict Off
Imports System
Imports NXOpen

Module organize_file

    Dim s As Session = Session.GetSession()
    Dim workPart As Part = S.Parts.Work
    Dim dispPart As Part = s.Parts.Display
    Dim lw As ListingWindow = s.ListingWindow
    Dim i As Integer
    Dim objArray(0) As DisplayableObject

    Sub Main()

        i = 100
        For Each sk As Sketch In s.Parts.Work.Sketches
            i = i + 1
            objArray(0) = sk
            workpart.Layers.MoveDisplayableObjects(i, objArray)
        Next

        

    End Sub

End Module

Chris T.
Project Design Analyst
Kohler Co. Engine Division
Using NX6
 
This will report the sketches in timestamp order:

Code:
[COLOR=blue]Option[/color] [COLOR=blue]Strict[/color] [COLOR=blue]Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  

[COLOR=blue]Module[/color] Module1  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
        [COLOR=blue]Dim[/color] workPart [COLOR=blue]As[/color] Part [COLOR=blue]=[/color] theSession.Parts.Work  
        [COLOR=blue]Dim[/color] lw [COLOR=blue]As[/color] ListingWindow [COLOR=blue]=[/color] theSession.ListingWindow  
        lw.Open()  

        [COLOR=blue]Dim[/color] mySketchFeature [COLOR=blue]As[/color] Features.SketchFeature  
        [COLOR=blue]Dim[/color] mySketch [COLOR=blue]As[/color] Sketch [COLOR=blue]=[/color] [COLOR=blue]Nothing[/color]  
        [COLOR=blue]Dim[/color] myFeatures() [COLOR=blue]As[/color] Features.Feature [COLOR=blue]=[/color] workPart.Features.ToArray  

        lw.WriteLine("Sketch Name" [COLOR=blue]&[/color] [COLOR=blue]New[/color] String(vbTab, 2) [COLOR=blue]&[/color] "Timestamp" [COLOR=blue]&[/color] [COLOR=blue]New[/color] String(vbTab, 1) [COLOR=blue]&[/color] "Layer")  
        [COLOR=blue]For[/color] [COLOR=blue]Each[/color] feat [COLOR=blue]As[/color] Features.Feature [COLOR=blue]In[/color] myFeatures  
            [COLOR=blue]If[/color] [COLOR=blue]TypeOf[/color] feat [COLOR=blue]Is[/color] Features.SketchFeature [COLOR=blue]Then[/color]  
                mySketchFeature [COLOR=blue]=[/color] feat  
                mySketch [COLOR=blue]=[/color] mySketchFeature.Sketch  
                lw.WriteLine(mySketch.Name [COLOR=blue]&[/color] [COLOR=blue]New[/color] String(vbTab, 2) [COLOR=blue]&[/color] feat.Timestamp [COLOR=blue]&[/color] [COLOR=blue]New[/color] String(vbTab, 2) [COLOR=blue]&[/color] mySketch.Layer)  
            End [COLOR=blue]If[/color]  
        [COLOR=blue]Next[/color]  
        lw.WriteLine("")  


    End [COLOR=blue]Sub[/color]  


    [COLOR=blue]Public[/color] [COLOR=blue]Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As[/color] [COLOR=blue]String[/color]) [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  

 [COLOR=green]'Unloads the image when the NX session terminates[/color]
        GetUnloadOption [COLOR=blue]=[/color] NXOpen.Session.LibraryUnloadOption.AtTermination  

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]


www.nxjournaling.com
 
Thank you very much cowski! This is exactly what I was looking for. Eventually, I plan on adding some code to this program to handle moving other objects to different layers as well...

Chris T.
Project Design Analyst
Kohler Co. Engine Division
Using NX6
 
Can you describe how this ordering of the file helps you? Since the sketches are already in time stamp order what is the additional benefit of having each sketch on it's own layer?

As a comparison our standard is to have all sketches for a specific part feature on a separate layer. For example all the sketches for the mounting tabs are on layer 29. We contain all the sketches in the 20-29 range. As another example, the main body of our parts are made up of a group of extruded features, with the sketches on layer 21 and a group of revolved features, with the sketches on layer 20.

I am always interested in how others organize their parts, and what benefits they get from the organization.

I am a big proponent of establishing standards based on principles not specifics. I am continually fighting with my companies organizational groups that come up with standards 6000 miles away having never asked how we do business here in our office where we have been doing business for 30 years establishing standards what work for our products. I am in favor of the ISO/TSO style of standardizing process where the directive is that you must look at what you do and define that as your standard, and then tweek it as needed.

Nice rant huh!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor