×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

sometimes it works sometimes not

sometimes it works sometimes not

sometimes it works sometimes not

(OP)
thread561-388210: color palette
Hi I try to use this journal but
sometimes it work fine , sometimes not (work only on a few part)


// NX 10.0.1.4
// Journal created by paul.turner V1 - 27/05/15
//
using System;
using System.IO;
using NXOpen;
using NXOpen.UF;
using NXOpen.Utilities;
using NXOpen.Assemblies;


public class NXJournal
{
// Cached NXOpen session
private static NXOpen.Session theSession;
private static NXOpen.UF.UFSession theUFSession;
private static NXOpen.Part workPart;
private static NXOpen.Part displayPart;

//----------------------------------------------------------------------
// Start with displayPart and process all parts in the assembly
public static void ProcessAssy()
{
//theSession.ListingWindow.Open();
try {
ComponentAssembly c = displayPart.ComponentAssembly;
ProcessPart(displayPart);
if (c.RootComponent != null) {
ProcessChildren(c.RootComponent, 0);
}
} catch (Exception e) {
//theSession.ListingWindow.WriteLine("Failed: " & e.ToString);
}
//theSession.ListingWindow.Close();

// reset the display part
NXOpen.PartLoadStatus partLoadStatus1;
NXOpen.PartCollection.SdpsStatus status1;
status1 = theSession.Parts.SetDisplay(displayPart, false, true, out partLoadStatus1);
partLoadStatus1.Dispose();
}
//----------------------------------------------------------------------
// This does not do the component loading
public static void ProcessChildren(Component comp, int indent )
{
foreach (Component child in comp.GetChildren()) {

// insert code to process component or subassembly
if (true /*LoadComponent(child)*/) {
//theSession.ListingWindow.WriteLine("old component name: " + child.Name);
//theSession.ListingWindow.WriteLine("file name: " + child.Prototype.OwningPart.Leaf);
// Get the Part() object
Part aPart = (Part) child.Prototype;
ProcessPart(aPart);
// child.SetName(child.Prototype.OwningPart.Leaf.ToUpper);
//lw.WriteLine("new component name: " & child.Name);
//lw.WriteLine("");
} else {
//component could not be loaded
}
// end of code to process component or subassembly
ProcessChildren(child, indent + 1);
}
}

//----------------------------------------------------------------------
// We know that they are Assemblies.Component objects, from our filter
private static void ProcessPart(Part aPart)
{
// HandleSelectionColor can only be called on DisplayedPart
// so change
NXOpen.PartLoadStatus partLoadStatus1;
NXOpen.PartCollection.SdpsStatus status1;
status1 = theSession.Parts.SetDisplay(aPart, true, true, out partLoadStatus1);
partLoadStatus1.Dispose();

// change the selection colours
aPart.Preferences.ColorSettingVisualization.SelectionColor = 119;
aPart.Preferences.ColorSettingVisualization.PreselectionColor = 149;

string rootDir = Environment.GetEnvironmentVariable("UGII_ROOT_DIR");
string colorPalette = rootDir + "\\ugcolor.cdf";
string colorName = "";
string red = "";
string green = "";
string blue = "";
double[] rgbColor = new double[3];
int thisColor = 0;
string textLine = "";
int lineCounter = 0;
Stream myStream = null;

//VB FileSystem.FileOpen(1, colorPalette, OpenMode.Input, -1, -1, -1);
System.IO.StreamReader file = new System.IO.StreamReader(@colorPalette);
//VB while (!(FileSystem.EOF(1)))
while ((textLine = file.ReadLine()) != null)
{
//VB textLine = FileSystem.LineInput(1);
if (lineCounter > 3)
{
colorName = textLine.Substring(0, 30);
red = textLine.Substring(34, 8);
green = textLine.Substring(45, 8);
blue = textLine.Substring(56, 8);
rgbColor[0] = Convert.ToDouble(red);
rgbColor[1] = Convert.ToDouble(green);
rgbColor[2] = Convert.ToDouble(blue);
thisColor = lineCounter - 4;
theUFSession.Disp.SetColor(thisColor, UFConstants.UF_DISP_rgb_model, colorName, rgbColor);
}
lineCounter++;
}
//VB FileSystem.FileClose(1);
file.Close();

theUFSession.Disp.LoadColorTable();
}


//----------------------------------------------------------------------
public static void Main(string[] args)
{
theSession = Session.GetSession();
theUFSession = UFSession.GetUFSession();
workPart = theSession.Parts.Work;
displayPart = theSession.Parts.Display;

// Undo
NXOpen.Session.UndoMarkId markId1;
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");
theSession.SetUndoMarkName(markId1, "Update Colours");

// Process the assembly
ProcessAssy();
}
public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }

}


Any suggestion please?

NX 7.5 64bit
NX 9.0.3.4 MP4 64bit
NX 10.0.3.5 MP3 64bit

www.studiotreccani.com

RE: sometimes it works sometimes not

Do you have write access to all the parts?

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX12 / TC11

RE: sometimes it works sometimes not

(OP)
Yes
The assembly and the parts, is saved on my computer
without any restriction.
And the files have a single directory for each project
(load from folder /OPTION) (fully load /OPTION)....
I actualy work with NX 12.0.2.9 MP4

NX 7.5 64bit
NX 9.0.3.4 MP4 64bit
NX 10.0.3.5 MP3 64bit

www.studiotreccani.com

RE: sometimes it works sometimes not

Something may have changed in the structures between 10.0.1 and 12.0.2.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

RE: sometimes it works sometimes not

The components which aren't changed, when you open them separately, do they get changed?

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX12 / TC11

RE: sometimes it works sometimes not

(OP)
NutAce,
yes if I run the program on the single part, that aren't change from the assembly,
it work.

I actualy work with NX 12.0.2.9 MP4
NX 10.0.3.5 MP3

www.studiotreccani.com

RE: sometimes it works sometimes not

(OP)
I found out the origin of the problem:
when there's a part suppressed
the journal does not processed all the files.
But I don't know how the avoid this issue...
Any help please.

I actualy work with NX 12.0.2.9 MP4
NX 10.0.3.5 MP3

www.studiotreccani.com

RE: sometimes it works sometimes not

I don't remember all the specifics, but I believe that when a component is explicitly suppressed, it won't be loaded the next time the assembly is opened. Also, if the component is set to non-geometric or reference only, it will be ignored by default (there is an environment variable to change this behavior).

I wrote some code a while back that attempts to open all the components of an assembly. However, I don't remember what happens to explicitly suppressed components...
http://nxjournaling.com/comment/718#comment-718

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

eBook - Manufacturing the Cars of Tomorrow
In this ebook, we'll explore how additive manufacturing is going to transform the way cars are made. This includes commentary from thought leaders such as Ford's CTO, Ken Washington, Customer case studies of ways 3D printing is being used today, and a variety of part examples where 3D printing is already impacting how automobiles are made. Download Now
White Paper - Smart Manufacturing for Semiconductor
New technologies and approaches present great opportunities for semiconductor manufacturers to achieve high levels of innovation, yield and improvement. This white paper explores some of these cutting-edge technologies and how they can be applied effectively in the semiconductor industry. Read about how Smart Manufacturing is transforming the semiconductor industry. Download Now
White Paper - Analysis and Simulation in Aircraft Structure Certification
Organizations using simulation and analysis tools effectively see the benefits in their ability to achieve certification faster and with drastically less total cost than those who do not maximize these tools. Read this White Paper to learn about how digital tools such as analysis and simulation help in aircraft structure certification. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close