Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Check annotation type

How can I check the drafting object type which is view label?

 

Thanks 

 

Terry

6 REPLIES

Re: Check annotation type

The View Label is 'UF_drafting_entity_type' and 'UF_draft_note_subtype'. 

 

You can find the type and subytpe of any object with this small vb journal.  Select a object and then run the journal.

 

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module journal

  Sub Main
    Dim s As Session = Session.GetSession()
    Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
    Dim selobj As NXObject
    Dim type As Integer
    Dim subtype As Integer
    Dim lw As ListingWindow = s.ListingWindow

    Dim theUI As UI = ui.GetUI
    Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
    lw.Open()
    lw.WriteLine("Selected Objects: " & numsel.ToString())

    For inx As Integer = 0 To numsel-1
      selobj = theUI.SelectionManager.GetSelectedObject(inx)

      ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
      lw.WriteLine("Object: " & selobj.ToString())
      lw.WriteLine(" Tag: " & selobj.Tag.ToString())
      lw.WriteLine(" Type: " & type.ToString())
      lw.WriteLine(" Subtype: " & subtype.ToString())
      lw.WriteLine("")
    Next

    End Sub

End Module

Re: Check annotation type

 UF_drafting_entity_type' and 'UF_draft_note_subtype are big group included many different drafting note object. I'm looking for specific view label drafting object for color editing using below:

CreateDrawingEditViewLabelSettingsBuilder

 Thanks

 

Terry

Re: Check annotation type

You can get the view label with 'UF_Draw_askviewlabel'.  If you are looping through NoteCollection, search for string VWLETTER or VWNAME.

 

Re: Check annotation type

Thanks for you help, I tried both your suggestions but I have below problems....

 

UF_DRAW_askviewlabel requires to provide the view tag but I can only use function UF_DRAW_ask_view_of_view_label to get this tag, it also needs view label tag to find view tag.....

 

The Section Line Label also has attribute string "VWLETTER" but it uses CreateAnnotationEditSettingBuilder but not CreateEditViewLabelSettingsBuilder for setting so it also won't help.

 

 

 

Solution
Solution
Accepted by topic author terchan1
‎12-30-2016 01:42 AM

Re: Check annotation type

If you just want to change the color of the label, it is quite easy.  Cobe below shows setting the color and creating EditViewLabelSettingsBuilder.

 

using System;
using NXOpen;
using NXOpen.Utilities;
using NXOpen.UF;
using NXOpen.Drawings;
using NXOpen.Drafting;

public class Program
{
    // class members
    private static Session theSession;
    private static UFSession theUfSession;
    public static Program theProgram;
    public static bool isDisposeCalled;

    //------------------------------------------------------------------------------
    // Constructor
    //------------------------------------------------------------------------------
    public Program()
    {
        try
        {
            theSession = Session.GetSession();
            theUfSession = UFSession.GetUFSession();
            isDisposeCalled = false;
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            // UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
        }
    }

    //------------------------------------------------------------------------------
    //  Explicit Activation
    //      This entry point is used to activate the application explicitly
    //------------------------------------------------------------------------------
    public static int Main(string[] args)
    {
        int retValue = 0;
        try
        {
            theProgram = new Program();

            //TODO: Add your application code here 
            Part workPart = theSession.Parts.Work;
            Tag viewLabelTag;

            NXOpen.Drawings.DraftingView[] draftViews = workPart.DraftingViews.ToArray();
            DisplayableObject[] theLabels = new DisplayableObject[draftViews.Length];

            for (int i=0; i<draftViews.Length; i++)
            {
                
                theUfSession.Draw.AskViewLabel(draftViews[i].Tag, out viewLabelTag);

                //If you want to just set the color
                theUfSession.Obj.SetColor(viewLabelTag, 6);

                //For creating EditViewSettingsBuuilder
                theLabels[i] = (DisplayableObject) NXObjectManager.Get(viewLabelTag);
            }

            //To create EditViewLabelSettingsBuilder
            EditViewLabelSettingsBuilder editViewLabelSettingsBuilder1;
            editViewLabelSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewLabelSettingsBuilder(theLabels);

            //Do whatever
            editViewLabelSettingsBuilder1.Destroy();

            theProgram.Dispose();
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----

        }
        return retValue;
    }

    //------------------------------------------------------------------------------
    // Following method disposes all the class members
    //------------------------------------------------------------------------------
    public void Dispose()
    {
        try
        {
            if (isDisposeCalled == false)
            {
                //TODO: Add your application code here 
            }
            isDisposeCalled = true;
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----

        }
    }

    public static int GetUnloadOption(string arg)
    {
        //Unloads the image explicitly, via an unload dialog
        //return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);

        //Unloads the image immediately after execution within NX
        // return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);

        //Unloads the image when the NX session terminates
        return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
    }

}

Hope this helps.

Re: Check annotation type

Many thanksSmiley Happy