Start a topic
With the exception of Windchill, The PTC Community is on read-only status until April 6 in preparation for moving our community to a new platform. Learn more here
cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here

Translate the entire conversation x

Regarding Toolkit ProDrawingViewDetailCreate and ProDrawingViewPartialVisibleAreaGet APIs cr

VP_14440689
10-Marble

Regarding Toolkit ProDrawingViewDetailCreate and ProDrawingViewPartialVisibleAreaGet APIs cr

Hi everyone,

I’m working with Creo 11 and trying to use the APIs ProDrawingViewDetailCreate and ProDrawingViewPartialVisibleAreaGet, both of which require a ref_point of type ProSelection. I’m facing consistent “bad input” errors and would appreciate any guidance from someone who has successfully implemented these.

Here’s what I’ve tried so far:

Method 1: Programmatic datum point creation

  • Created a datum point → Success

  • Used ProPointInit → Success

  • Converted using ProPointToGeomitem and Modelitem APIs → Success

  • Attempted ProSelectionAlloc() → Failed to return a valid ProSelection

Method 2: Manual selection approach

  • Created a datum point

  • Selected the point using ProSelection → Success

  • Passed this selection to ProDrawingViewDetailCreate & ProDrawingViewPartialVisibleAreaGet → Both failed with “bad inputs”

Method 3: Drawing entity approach

  • Created a point in the drawing using ProDtlEntityCreate

  • Used ProSelectionAlloc() → Success

  • Passed it to ProDrawingViewDetailCreate & ProDrawingViewPartialVisibleAreaGet → Still getting “bad input” errors

At this point, I suspect I might be missing something about the expected reference context (model space vs drawing space selection, view ownership, or selection type).

Has anyone successfully passed a valid ref_point selection to these APIs in Creo 11? Any example workflow or clarification on what kind of ProSelection these functions strictly expect would be really helpful.

Thanks in advance!

ACCEPTED SOLUTION

Accepted Solutions
VP_14440689
10-Marble
(To:RPN)

Hello sir, 
I got the source code from community post and it worked, you were right the real challenge was to get the Curvedata i.e to create the spline

from this code its very clear now and now I am able to deal with all those APIs who need Curedata.
Thank you so much for your time and help.

Link - https://community.ptc.com/t5/Customization/Regarding-Toolkit-ProDrawingViewDetailCreate-and/m-p/1055064

 

View solution in original post

7 REPLIES 7

Not a datum, it is just the placement/reference point

set x and y with

ProSelectionPoint3dSet( ProPoint3d point, ProSelection *p_prosel);

Just my 2 Cents 🧐😂😉

VP_14440689
10-Marble
(To:RPN)

Hi,

Thanks for the suggestion regarding using a placement/reference point with ProSelectionPoint3dSet. I tried multiple approaches based on that idea and wanted to share what I tested and the results I’m seeing.

What I implemented:

  1. View creation

  • I create a general view using ProDrawingGeneralviewCreate.

  • Apply display style and regenerate the view:

    • ProDrawingViewDisplaySet

    • ProDrawingViewRegenerate

  • I can successfully create projected views and an isometric view from the same parent view, so the view itself is valid and visible.

  1. Reference point using ProSelectionPoint3dSet

  • I followed the suggestion to not use a datum/model entity and instead create a placement selection:

    • ProSelectionAlloc(NULL, NULL, &ref_sel)

    • ProSelectionViewSet(general_view, &ref_sel)

    • ProSelectionPoint3dSet(pick_pt, &ref_sel)

  • For the point, I tried:

    • Hard-coded sheet coordinates

    • Center of the view outline

    • A user-picked point via ProMousePickGet

  • All three cases:

    • ProSelectionAlloc → success

    • ProSelectionViewSet → success

    • ProSelectionPoint3dSet → success

  1. Boundary creation

  • I build a circular boundary using:

    • ProArcdataInit(v1, v2, pick_pt, 0, 2*M_PI, radius, &circle)

  • This also succeeds consistently.

  1. Detail view creation

  • Then I call:

    ProDrawingViewDetailCreate(
        current_drw,
        general_view,
        ref_sel,
        &circle,
        view_loc,
        &detail_view
    );
  • Result:

    PRO_TK_BAD_INPUTS (-2)
  1. Additional attempts

  • Tried both:

    • Hardcoded reference point

    • Mouse-picked point inside the parent view

  • Tried placing the detail view well away from the parent view using the parent view outline.

  • Also attempted ProDrawingViewDetailReferenceSet with the same selection → also returns PRO_TK_BAD_INPUTS.

So at this point, I’m able to:

  • Create a valid selection with:

    • View context

    • Point attached using ProSelectionPoint3dSet

  • Create the circular boundary

But ProDrawingViewDetailCreate and ProDrawingViewDetailReferenceSet still report “bad inputs”.

If there’s any additional requirement for the reference point (for example, it needing to lie exactly on projected geometry or needing a model-backed selection instead of a pure view+point selection), I’d appreciate clarification.

Thanks again for the pointer — it helped narrow down the problem significantly.

VP_14440689
10-Marble
(To:RPN)

Hi, I tried it again but it didn't worked out 😞

I tried your approach of using ProSelectionPoint3dSet() to create the reference point, but in my case it didn’t work and Creo actually crashed when I proceeded with ProDrawingViewDetailCreate(). So I wanted to share what I tested and the behavior I observed.

I am working completely inside a drawing. First I get the current model and create a general view successfully. Then I pick an edge from the drawing view using:

ProSelect("edge", 1, NULL, NULL, NULL, NULL, &sel_array, &n_sel);

From that selection I extract the picked location using:

ProSelectionPoint3dGet(sel_array[0], pt);

This part works fine and I can log the coordinates:
Edge picked at -> X: 10.104 Y: 11.086 Z: 1.000

Then I get the parent view from the selection and transform the point from view space to drawing space using:

  • ProSelectionViewGet()

  • ProDrawingViewTransformGet(..., PRO_B_TRUE, ...)

  • ProPntTrfEval()

After that I use the transformed point to create the circle boundary (ProArcdataInit) and that part also succeeds. My log shows:

[Creo Success] ProDrawingViewTransformGet
[Creo Success] ProPointdataInit
[Creo Success] Pick perimeter
[Creo Success] ProArcdataInit

Finally, I call:

ProDrawingViewDetailCreate(
current_drw,
general_view,
sel_array[0], // ref_point
&crv_data,
location,
&detail_view);

At this stage Creo becomes unstable / crashes. When I tried the alternative approach of manually creating a selection and setting a point using ProSelectionPoint3dSet(), it did not behave as a valid reference point for the detail view either.

So in my case, simply setting X and Y using ProSelectionPoint3dSet() on a manually allocated selection did not produce a stable ref_point for ProDrawingViewDetailCreate(). Using the actual picked selection from the drawing view seems closer to correct, but I’m still hitting a failure/crash at the detail creation step.

If you have a minimal working snippet where ProSelectionPoint3dSet() alone is enough for a detail view ref_point (in a drawing context), I’d really appreciate seeing how that selection is constructed and what object you allocate it against.

here is the code 

    // Get current model
    ProMdl current_mdl;
    ProError status = ProMdlCurrentGet(&current_mdl);
    if (status != PRO_TK_NO_ERROR) {
        log_info("WARNING: No model open. Please open a drawing.");
        return 0;
    }

    log_info("The Model handle is built successfully.");

    // Log model name
    ProMdlName mdl_name;
    ProMdlMdlnameGet(current_mdl, mdl_name);
    char mdl_name_str[PRO_MDLNAME_SIZE];
    ProWstringToString(mdl_name_str, mdl_name);
    log_info("The name of the model is: " + string(mdl_name_str));

    ProDrawing current_drw = (ProDrawing)current_mdl;
    ProSolid drw_solid_mdl;
    ProDrawingCurrentsolidGet(current_drw, &drw_solid_mdl);

    int sheet_id;
    ProDrawingCurrentSheetGet(current_drw, &sheet_id);



    // Bounding box for spacing
    Pro3dPnt bbox[2];
    ProSolidOutlineGet(drw_solid_mdl, bbox);

    double model_w = bbox[1][0] - bbox[0][0];
    double model_h = bbox[1][1] - bbox[0][1];

    double scale = 2.0;
    double view_w = model_w / scale;
    double view_h = model_h / scale;

    ProPoint3d general_pos{ 400.00, 500.00 };

    ProMatrix orientation = {
        {1,0,0,0},
        {0,1,0,0},
        {0,0,1,0},
        {0,0,0,1},
    };

    ProView general_view;


    status = ProDrawingGeneralviewCreate(current_drw, drw_solid_mdl, sheet_id, PRO_B_FALSE, general_pos, scale, orientation, &general_view);

    ProSelection* sel_array = NULL;
    int n_sel = 0;
    ProPoint3d pt;

    ProSelect("edge", 1, NULL, NULL, NULL, NULL, &sel_array, &n_sel);

    if (n_sel > 0)
    {
        status  = ProSelectionPoint3dGet(sel_array[0], pt);

        char buffer[200];
        sprintf(buffer, "Edge picked at -> X: %.3f  Y: %.3f  Z: %.3f",
            pt[0], pt[1], pt[2]);

        log_info(buffer);
        ProView view;
        status = ProSelectionViewGet(sel_array[0], &view);

        ProMatrix matrix;
        status = ProDrawingViewTransformGet(
            current_drw,
            view,
            PRO_B_TRUE,   // VIEW  DRAWING
            matrix);

        visit_items::CheckError(status, "ProDrawingViewTransformGet");

        ProPoint3d sheet_pt;

        ProPntTrfEval(pt, matrix, sheet_pt);
        



        ProPoint3d center_pnt;
        ProMouseButton btn;
        Pro3dPnt perimeter_pnt;
        //center_pnt[0] = pt[0];
        //center_pnt[1] = pt[1];
        //center_pnt[2] = pt[2];

        center_pnt[0] = sheet_pt[0];
        center_pnt[1] = sheet_pt[1];
        center_pnt[2] = 0.0;


        ProCurvedata crv_data;
        status = ProPointdataInit(center_pnt, &crv_data);
        visit_items::CheckError(status, "ProPointdataInit");

        ProDtlentitydata ent_data;
        ProDtlentity entity;

        status = ProDtlentitydataAlloc(current_drw, &ent_data);
        status = ProDtlentitydataCurveSet(ent_data, &crv_data);

        int sheet;
        //ProView view;
        ProDrawingCurrentSheetGet(current_drw, &sheet);
        ProDrawingBackgroundViewGet(current_drw, sheet, &view);
        ProDtlentitydataViewSet(ent_data, view);

        ProDtlentityCreate(current_drw, NULL, ent_data, &entity);
        ProDtlentityDraw(&entity);

        status = ProMousePickGet(PRO_ANY_BUTTON, &btn, perimeter_pnt);
        visit_items::CheckError(status, "Pick perimeter");

        ProVector diff;
        VectorDiff(perimeter_pnt, center_pnt, diff);
        double radius = VectorLength(diff);


        ProVector vector1 = { 1.0, 0.0, 0.0 };
        ProVector vector2 = { 0.0, 1.0, 0.0 };
        double start_angle = 0.0;
        double end_angle = 2 * M_PI;

        status = ProArcdataInit(vector1, vector2, center_pnt,
            start_angle, end_angle, radius,
            &crv_data);
        visit_items::CheckError(status, "ProArcdataInit");

        status = ProDtlentitydataAlloc(current_drw, &ent_data);
        status = ProDtlentitydataCurveSet(ent_data, &crv_data);

        ProDrawingCurrentSheetGet(current_drw, &sheet);
        ProDrawingBackgroundViewGet(current_drw, sheet, &view);
        ProDtlentitydataViewSet(ent_data, view);

        ProDtlentityCreate(current_drw, NULL, ent_data, &entity);
        ProDtlentityDraw(&entity);

        ProDtlentitydataFree(ent_data);


        ProView detail_view;
        ProPoint3d location = { 500, 500, 0 };
        status = ProDrawingViewDetailCreate(
            current_drw,
            view,
            sel_array[0],   // ref_point
            &crv_data,
            location,
            &detail_view);

        visit_items::CheckError(status, "ProDrawingViewDetailCreate");
        if (status != PRO_TK_NO_ERROR) {
            return 0;
           
        }

The best is to understand the requirements by creating first a detail view manually.

 

For some drawing functions calls it is important that the drawing is active. For your function calls,  the 3D model is already known by the reference view. The tricky part is to automate the view reference and the spline outline.

The view reference point is used to regen the detailed view. As mentioned in the header file. The reference point must be enclosed by the spline. Maybe first create a spline in the drawing, maybe with 4 points, and check the outcome. You can try first to make the spline manually in the drawing, next read and use it in the function call.


The reference point must be a valid 3D model selection, an endpoint of on edge. 

 

From the header file:

The curve_data spline is in world space, and must enclose the reference point (in world space, on the parent view).

 

Not sure if you can use a simple arc, because if I remember you pick an area for what you would like to see later.

 

The location is just a pick point, and may need to transformed from window to drawing coordinates. 

I can’t proof everything by 100% because I’m not in front of a Creo Toolkit Session😉

 

Not sure if something like this is required.

 

Next: this may required for spline setup😵💫 see the header for more details, there are a couple of other functions as well.

*/

extern ProError ProDrawingViewDetailCurvedataSet (ProDrawing drawing, ProView view, ProCurvedata* curve_data);
/*
Purpose: Set spline for detail view parent

Input Arguments:
drawing - Drawing handle
view - The view handle
curve_data - Spline data (see Notes: below)

 

VP_14440689
10-Marble
(To:RPN)

Thank you so much sir,  I will go through the document and try to do it.

VP_14440689
10-Marble
(To:RPN)

Hello sir, 
I got the source code from community post and it worked, you were right the real challenge was to get the Curvedata i.e to create the spline

from this code its very clear now and now I am able to deal with all those APIs who need Curedata.
Thank you so much for your time and help.

Link - https://community.ptc.com/t5/Customization/Regarding-Toolkit-ProDrawingViewDetailCreate-and/m-p/1055064

 

Hello @VP_14440689,

 

It looks like you have some responses from a community expert. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Announcements



Top Tags