Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Picking a WCS


Recommended Posts

I think you need NamedViews/named_view_manager.

 

code:

 

 

#define VIEWARRAY CArray <view_ent, view_ent> ///< Array of view_ents

 

extern DllImpExp VIEWARRAY NamedViews; ///< Current array of named views

extern DllImpExp CArray <view_icon, view_icon> NamedViewIcons; ///< Current array of named view icons

extern DllImpExp MC_BOOL SetOriginOnSaveNewViewDlg; ///< Specifies whether to set the cplane or tplane origin when this new view is selected for use as a cplane or tplane

 

 

/**

*

* @par Purpose:

* function to add/get/delete/edit named views in the current db

*

* @param[in,out] vwp pointer to named view entity

* @param[in] mode VWMGR_ADD, VWMGR_RENAME, etc.

* @param[in] new_name new view name (for VWMGR_RENAME only) or "" (null string)

* @param[out] succf TRUE = view manager successful

*

*/

DllImpExp void named_view_manager (

view_ent *vwp,

short mode,

char *new_name,

MC_BOOL *succf);


Link to comment
Share on other sites

Thanks for the response Takashi. I'm sorry I haven't got back to you sooner but I have been working on other problems.

 

I have experimented with using named_view_manager and found the using VWMGR_SELECT for the mode argument allows the user to select a view. However, the view structure returned has an m field which gives the X, Y and Z rotation of the view but does not contain the origin of the view. Is there a way to get this information?

 

Thanks

Link to comment
Share on other sites

CaKiwi,

 

View Origin... World or View ?

 

In the view_ent struct there is this member ->

 

assoc_pt pts[4]; //< [0]=origin, [1]-[3] orientation all in world coordinates

 

This [0]=origin struck me as something I should look into.

 

Looking at the View info (via the View manager in Mastercam) I see this data ->

 

code:

View Id #       : 8

Name : NEW VIEW [8]

Comment :

Origin : X-0.36120188 Y-0.68597797 Z0.

Number : 20

Matrix : X0.36822397 Y-0.89244705 Z-0.26067102

: X-0.89244705 Y-0.26067102 Z-0.36822397

: X0.26067102 Y0.36822397 Z-0.89244705

Associative : Yes

pts[0]: ent_idn 11 , eptr 149716256 , method E

pts[1]: ent_idn 11 , eptr 149716256 , method E

pts[2]: ent_idn 9 , eptr 149716192 , method E

Color : 10

Used in toolpath : No

But when I looked at the X,Y,Z data in pt[0] of the view_ent I had these values ->

0.47919581977711789

0.50116812077418260

0.34674839070776653

 

Hmmm...

Doesn't match up with -> Origin : X-0.36120188 Y-0.68597797 Z0.

 

But wait!

In View Manager where is lists the Origin it says -> Origin (in View Coordinates)

 

I added this command to my code -> world_to_view (v.pts[0].pt, v.view_n, vpt);

and out comes the Origin values I was looking for in vpt.

 

Sweet! smile.gif

 

code:

MC_BOOL MySelectView()

{

view_ent v;

MC_BOOL succf;

p_3d vpt;

named_view_manager(&v, VWMGR_SELECT, "", &succf);

world_to_view (v.pts[0].pt, v.view_n, vpt);

// vpt now contains the View Origin (in View Coordinates)

return succf;

}

Link to comment
Share on other sites
  • 1 year later...

I try to make a plane to 100mm from TOP, what I miss?

code:

 		MC_BOOL succf;

ent e;

view_ent vEnt;

memset(&vEnt,0,sizeof(view_ent));

DB_LIST_ENT_PTR e_ptr;

p_3d TempP;

assoc_pt origin, xaxis, yaxis, zaxis;

char neveme = NULL;

 

TempP[0]=100, TempP[1]=0, TempP[2]=0; // Origin

copy_p_3d(origin.pt, TempP);

TempP[0]=110, TempP[1]=0, TempP[2]=0; // Xaxis

copy_p_3d(xaxis.pt, TempP);

TempP[0]=100, TempP[1]=10, TempP[2]=0; // Yaxis

copy_p_3d(yaxis.pt, TempP);

TempP[0]=100, TempP[1]=0, TempP[2]=10; // Zaxis

copy_p_3d(zaxis.pt, TempP);

 

vEnt.color = 12;

memcpy(vEnt.comment, "Plane - 100mm", 256*sizeof(char));

vEnt.rel_type = VREL_TOP;

vEnt.vw_method = VM_3PTS;

vEnt.type = -1;

vEnt.assoc = false;

vEnt.used_in_op = false;

vEnt.set_origin = false;

memcpy(vEnt.vname, "SZUKA", 41*sizeof(char));

vEnt.woff_n = 2;

vEnt.display = 1;

vEnt.pts[0] = origin;

vEnt.pts[1] = xaxis;

vEnt.pts[2] = yaxis;

vEnt.pts[3] = zaxis;

store_ent(&e, &e_ptr, 0, e.color, e.level, e.a, &succf);

named_view_manager(&vEnt, VWMGR_ADD, &neveme, &succf);

BTW, how can I rotate & save a plane?

Thanxx for any help & advice!

Link to comment
Share on other sites

I assumed that '100mm from TOP' meant the you wanted the origin to be X0,Y0,Z100

 

Original code:

origin.pt is not correct => X100, Y0, Z0

and

The Matrix for the view is not defined

 

Get you this ->

 

code:

View Id #           : 8

Name : SZUKA

Comment : Plane - 100mm

Origin : X0. Y0. Z0.

Number : 19

Matrix : X0. Y0. Z0.

: X0. Y0. Z0.

: X0. Y0. Z0.

Associative : No

Color : 12

Used in toolpath : No

Corrected code:

 

changed:

TempP[0]=0, TempP[1]=0, TempP[2]=100; // Origin

 

and added:

 

// This is TOP view matrix...

// typedef p_3d matrix_33 [3]; ///< 3x3 matrix

vEnt.m[0][X] = 1;

vEnt.m[0][Y] = 0;

vEnt.m[0][Z] = 0;

 

vEnt.m[1][X] = 0;

vEnt.m[1][Y] = 1;

vEnt.m[1][Z] = 0;

 

vEnt.m[2][X] = 0;

vEnt.m[2][Y] = 0;

vEnt.m[2][Z] = 1;

 

origin.pt => X0, Y0, Z100

and

The with a proper Matrix

 

code:

View Id #           : 8

Name : SZUKA

Comment : Plane - 100mm

Origin : X0. Y0. Z100.

Number : 1

Matrix : X1. Y0. Z0.

: X0. Y1. Z0.

: X0. Y0. Z1.

Associative : No

Color : 12

Used in toolpath : No

Or you could something like this ->

 

code:

// Load a view_ent with the data from the specified view#

MC_BOOL GetView(view_ent *view, int view_n)

{

MC_BOOL succf;

memset (view, 0, sizeof (view_ent));

view->v_idn = view_n;

named_view_manager(view, VWMGR_GET, _T(""), &succf);

return succf;

}

 

// Make a new view based on an existing view

MC_BOOL MakeView()

{

view_ent vEnt;

memset(&vEnt,0,sizeof(view_ent));

int view_n = 1; // TOP

MC_BOOL succf = GetView(&vEnt, view_n);

if (succf)

{

vEnt.v_idn = 0; // So VWMGR_ADD will auto make a new id#

 

// Set what you want different than the original View

vEnt.assoc = false;

vEnt.used_in_op = false;

vEnt.set_origin = false;

memcpy(vEnt.vname, "SZUKA", 41*sizeof(char));

vEnt.woff_n = 2;

vEnt.display = 1;

vEnt.color = 12;

memcpy(vEnt.comment, "Plane - 100mm", 256*sizeof(char));

 

// Set the Origin Pt

vEnt.pts[0].pt[X] = 0.0;

vEnt.pts[0].pt[Y] = 0.0;

vEnt.pts[0].pt[Z] = 100.0;

 

named_view_manager(&vEnt, VWMGR_ADD, _T(""), &succf);

}

return succf;

}

*** BTW, how can I rotate & save a plane? ***

 

You want to crate a new View that is rotated from another (original) view ?

Link to comment
Share on other sites
  • 4 weeks later...
  • 7 years later...

Hi,
unfortunatly i can't get the list of all names of WCS's under 2017 no more?
Neither the

extern DllImpExp VIEWARRAY NamedViews; ///< Current array of named views

nor the named_view_manager(...) worked for me.
How can we get the mentioned list of WCS's under 2017/2018?

Thanks in advance

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...