Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 787

Error when using winform with C#

$
0
0

Please help me :((
When using winform, after executing the function. NX always displays the message board: Work in process, Click stop to interput this operator.
How does NX finish after function execution?

Code: Event click to table, select face change color.

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing; 
usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingNXOpen;usingNXOpenUI; 
namespace ColorTable
{staticclass Program
    {/// <summary>/// The main entry point for the application./// </summary>[STAThread]publicstaticvoid Main(string[] args){
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());}publicstaticint GetUnloadOption(string dummy){return(int)NXOpen.Session.LibraryUnloadOption.Immediately;}} 
publicpartialclass Form1 : Form
    {public Form1(){
            InitializeComponent();} 
        List<DisplayableObject> mySelectedObjects =new List<DisplayableObject>(); 
        publicstatic Selection.Response SelectmultiObkjects(string prompt, ref List<DisplayableObject> dispObj ){
            TaggedObject[] selObj;
            UI theUI = UI.GetUI();string title ="Select face";
            Selection.SelectionAction selAction = Selection.SelectionAction.ClearAndEnableSpecific;
            Selection.SelectionScope scope = Selection.SelectionScope.AnyInAssembly;
            Selection.MaskTriple[] selectionMask_array =new Selection.MaskTriple[1];
            selectionMask_array[0].Type= NXOpen.UF.UFConstants.UF_face_type;
            selectionMask_array[0].SolidBodySubtype= NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY; 
            Selection.Response resp = theUI.SelectionManager.SelectTaggedObjects(prompt, title, scope, selAction, false, false, selectionMask_array, out selObj); 
            if(resp == Selection.Response.ObjectSelected|| resp == Selection.Response.ObjectSelectedByName|| resp == Selection.Response.Ok){foreach(NXObject item in selObj){
                    dispObj.Add((NXOpen.DisplayableObject)item);}return Selection.Response.Ok;}else{return Selection.Response.Cancel;}} 
        privatevoid listView1_SelectedIndexChanged(object sender, EventArgs e){
        Session theSession = Session.GetSession();
        Part workPart = theSession.Parts.Work;
        Part displayPart = theSession.Parts.Display; 
        UI theUI = UI.GetUI(); 
 
 
            if(SelectmultiObkjects("Color Table (Code by Mold CADCAM P)", ref mySelectedObjects)== Selection.Response.Ok){
                NXOpen.DisplayModification displayModification1; 
                displayModification1 = theSession.DisplayManager.NewDisplayModification(); 
 
              displayModification1.ApplyToAllFaces=true; 
 
                displayModification1.ApplyToOwningParts=true; 
 
                displayModification1.NewColor=186; 
 
                displayModification1.Apply(mySelectedObjects.ToArray()); 
 
                displayModification1.Dispose(); 
            }}} 
partialclass Form1
    {/// <summary>/// Required designer variable./// </summary>privateSystem.ComponentModel.IContainer components =null; 
        /// <summary>/// Clean up any resources being used./// </summary>/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>protectedoverridevoid Dispose(bool disposing){if(disposing &&(components !=null)){
                components.Dispose();}base.Dispose(disposing);} 
        #region Windows Form Designer generated code 
        /// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>privatevoid InitializeComponent(){System.Windows.Forms.ListViewItem listViewItem1 =newSystem.Windows.Forms.ListViewItem(newSystem.Windows.Forms.ListViewItem.ListViewSubItem[]{newSystem.Windows.Forms.ListViewItem.ListViewSubItem(null, "91"),
            newSystem.Windows.Forms.ListViewItem.ListViewSubItem(null, "", System.Drawing.SystemColors.WindowText, System.Drawing.Color.Blue, newSystem.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))))}, -1);this.listView1=newSystem.Windows.Forms.ListView();this.columnHeader1=((System.Windows.Forms.ColumnHeader)(newSystem.Windows.Forms.ColumnHeader()));this.columnHeader2=((System.Windows.Forms.ColumnHeader)(newSystem.Windows.Forms.ColumnHeader()));this.columnHeader3=((System.Windows.Forms.ColumnHeader)(newSystem.Windows.Forms.ColumnHeader()));this.SuspendLayout();// // listView1// this.listView1.Columns.AddRange(newSystem.Windows.Forms.ColumnHeader[]{this.columnHeader1,
            this.columnHeader2,
            this.columnHeader3});this.listView1.FullRowSelect=true;this.listView1.GridLines=true;this.listView1.Items.AddRange(newSystem.Windows.Forms.ListViewItem[]{
            listViewItem1});this.listView1.Location=newSystem.Drawing.Point(-1, 2);this.listView1.Name="listView1";this.listView1.Size=newSystem.Drawing.Size(599, 507);this.listView1.TabIndex=0;this.listView1.UseCompatibleStateImageBehavior=false;this.listView1.View=System.Windows.Forms.View.Details;this.listView1.SelectedIndexChanged+=newSystem.EventHandler(this.listView1_SelectedIndexChanged);// // columnHeader1// this.columnHeader1.Text="Code";// // columnHeader2// this.columnHeader2.Text="Color";this.columnHeader2.TextAlign=System.Windows.Forms.HorizontalAlignment.Center;this.columnHeader2.Width=80;// // columnHeader3// this.columnHeader3.Text="Tolerance";this.columnHeader3.TextAlign=System.Windows.Forms.HorizontalAlignment.Center;this.columnHeader3.Width=151;// // Form1// this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F, 13F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.ClientSize=newSystem.Drawing.Size(739, 501);this.Controls.Add(this.listView1);this.Name="Form1";this.Text="Form1";this.ResumeLayout(false); 
        } 
        #endregion 
        privateSystem.Windows.Forms.ListView listView1;privateSystem.Windows.Forms.ColumnHeader columnHeader1;privateSystem.Windows.Forms.ColumnHeader columnHeader2;privateSystem.Windows.Forms.ColumnHeader columnHeader3;} 
}

Viewing all articles
Browse latest Browse all 787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>