cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict block selection to curve/edges

Pioneer
Pioneer
Hi, I am using selection0->GetProperties()->SetSelectionFilter("SelectionFilter",Selection:Smiley FrustratedelectionAction:Smiley FrustratedelectionActionClearAndEnableSpecific,mask); where mask is std::vector:masktriple> mask; Selection::MaskTriple MT1( UF_line_type, 0, 0 ); Selection::MaskTriple MT2( UF_circle_type, 0, 0 ); Selection::MaskTriple MT3( UF_conic_type, 0, 0 ); Selection::MaskTriple MT4( UF_edge_type, 0, 0 ); Selection::MaskTriple MT5( UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE); Selection::MaskTriple MT6( UF_section_edge_type, 0, 0 ); Selection::MaskTriple MT7( UF_solid_silhouette_type, 0, 0 ); I have to restrict block selection to curves. edges in drafting view, Currently it selects point also(like startpoint,endpoint of line,Arc center, Mid point of curve/line). I am using UF_DRAW_ask_drafting_curve_type& UF_DRAW_ask_drafting_curve_parents( curve,&n_parents, &parents), if i select point thats where i get the error if(n_parents>0} { component_found = UF_ASSEM_ask_part_occurrence(parents[0]); }:masktriple>
4 REPLIES

Re: Restrict block selection to curve/edges

Siemens Phenom Siemens Phenom
Siemens Phenom

 

I tried this without the Block Styler, just the normal selection dialog, and I am not able to select points or endpoints.

 

#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_disp.h>
#include <uf_part.h>
#include <uf_object_types.h>
#include <uf_ui.h>

#include <stdarg.h>

#pragma warning(disable:4996)

static void ECHO(char *format, ...)
{
    char msg[UF_UI_MAX_STRING_LEN+1];
    va_list args;
    va_start(args, format);
    vsprintf(msg, format, args);
    va_end(args);
    UF_UI_open_listing_window();
    UF_UI_write_listing_window(msg);
    UF_print_syslog(msg, FALSE);
}

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

static int report_error( char *file, int line, char *call, int irc)
{
    if (irc)
    {
        char err[133];

        UF_get_fail_message(irc, err);
        ECHO("*** ERROR code %d at line %d in %s:\n",
            irc, line, file);
        ECHO("+++ %s\n", err);
        ECHO("%s;\n", call);
    }

    return(irc);
}

static int mask_for_curves_and_edges(UF_UI_selection_p_t select, void *type)
{
    UF_UI_mask_t
        mask[5] = { { UF_line_type, 0, 0 },
                    { UF_circle_type, 0, 0 },
                    { UF_conic_type, 0, 0 },
                    { UF_spline_type, 0, 0 },
                    { UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE } };

    if (!UF_CALL(UF_UI_set_sel_mask(select,
            UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, 5, mask)))
        return (UF_UI_SEL_SUCCESS);
    else
        return (UF_UI_SEL_FAILURE);
}

static int select_curves_or_edges(char *prompt, tag_t **curves)
{
    int
        cnt,
        ii,
        resp;

    UF_CALL(UF_UI_select_with_class_dialog("Select curves or edges", prompt,
        UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY,
        mask_for_curves_and_edges, NULL, &resp, &cnt, curves));

    for (ii = 0; ii < cnt; ii++)
        UF_CALL(UF_DISP_set_highlight((*curves)[ii], FALSE));

    return cnt;

}

static void do_it(void)
{
    tag_t
        *picked = NULL;
    int
        count = 0;

    count = select_curves_or_edges("Pick curves or edges:", &picked);

    if(count > 0)
    {
        ECHO("%d curves/edges were selected\n", count);
        UF_free(picked);
    }



}

/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
    if (UF_CALL(UF_initialize())) return;
    do_it();
    UF_terminate();
}

int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}

Re: Restrict block selection to curve/edges

Siemens Phenom Siemens Phenom
Siemens Phenom

Update:  I tested with a SelectObject block in a Block UI Styler dialog, and I found that  I had to set the PointOverlay property to False to prevent the selection of end points:

 

   '------------------------------------------------------------------------------
    'Callback Name: initialize_cb
    '------------------------------------------------------------------------------
    Public Sub initialize_cb()
        Try

            group0 = theDialog.TopBlock.FindBlock("group0")
            selection0 = theDialog.TopBlock.FindBlock("selection0")

            selection0.GetProperties().SetLogical("PointOverlay", False)

            Dim mask(6) As Selection.MaskTriple
            With mask(0)
                .Type = UFConstants.UF_line_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(1)
                .Type = UFConstants.UF_circle_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(2)
                .Type = UFConstants.UF_conic_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(3)
                .Type = UFConstants.UF_spline_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(4)
                .Type = UFConstants.UF_section_edge_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(5)
                .Type = UFConstants.UF_solid_silhouette_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
            With mask(6)
                .Type = UFConstants.UF_solid_type
                .Subtype = 0
                .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
            End With

            selection0.GetProperties.SetSelectionFilter("SelectionFilter", _
                Selection.SelectionAction.ClearAndEnableSpecific, mask)



        Catch ex As Exception

            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        End Try
    End Sub

Re: Restrict block selection to curve/edges

Pioneer
Pioneer

Perfect! Thanks alot Smiley Happy

Re: Restrict block selection to curve/edges

Esteemed Contributor
Esteemed Contributor

Just to reference the latest additions, GetProperties() is no longer needed starting with NX 8.0, since most properties are exposed in their own direct method.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community