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:

Dynamically modifying line's endpoint via chook


Recommended Posts

I'm trying to write a chook that would select a line and modify its endpoint dynamically, or by sketching/selecting a point in graphics space. This functionality would be similar to Mastercam's 'Edit->Modify NURBS' functionality.

 

I'm searching for chook functions that would help me do this. Currently, I'm using point_proc(), and it doesn't sketch a point in desired 3d space.

The point_proc() method gives a point that is lying in a plane normal to the selected original line.

 

-------------------------------------------

 

//Select the line

 

select_ent("Select a line to modify", &oEntity, &oDBEntity, oPtSelect, dTParam, ALIVE_BIT, ALL_ENTITIES_MASK, select_color, &bSuccess);

 

// Get the curve endpoints

p_3d aStartPoint, aEndPoint;

curve_endpoints(&oEntity, aStartPoint, aEndPoint);

 

 

// Ask for new point

while(true)

{

 

ent oLineVector;

DB_LIST_ENT_PTR d_ptr;

 

char Option;

p_3d oNewSelectedPoint;

Point_proc ("Select new position, Escape to finish", &Option, oNewSelectedPoint, &bSuccess);

 

if(!bSuccess) break;

 

oLineVector.id = L_ID;

vec_3d(aStartPoint[X], aStartPoint[Y], aStartPoint[Z], oLineVector.u.li.e1);

 

vec_3d(oNewSelectedPoint[X], oNewSelectedPoint[Y], oNewSelectedPoint[Z], oLineVector.u.li.e2);

 

store_ent(&oLineVector, &d_ptr, 0, main_color, main_level, main_attrib, &bSuccess);

 

repaint_graphics();

 

}

 

-----------------------------------------

 

Thanks in advance for any help.

Link to comment
Share on other sites

I'm guessing unless you're selecting your point off another entity when you select a point off 'in space' Mastercam will interpret your point to be in a plane defined by the Z construction Level.

 

Also as a side note; in select_ent above you can force it too select only lines by changing ALL_ENTITIES_MASK to L_ID. That is, unless you're trying to get splines and stuff too, then my bad. sorry.

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...