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:

Modifying Line's endpoint via chook


MRB
 Share

Recommended Posts

I want to write a chook that would select a line and modify its endpoint in real time, 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.

Please let me know how I can do this. Thanks very much.

 

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

Code so far

 

select_ent("Select a line", &oEntity, .....);

p_3d aStartPoint, aEndPoint;

curve_endpoints(&oEntity, aStartPoint, aEndPoint);

 

while(true)

{

p_3d oNewSelectedPoint;

point_proc ("Pick new position, Escape to finish", &Option, oNewSelectedPoint, &bSuccess);

 

//Make and store new line using above point

 

}

 

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

Link to comment
Share on other sites

//Make and store new line using above point

 

// erase the line

draw_ent(&oEntity, gr_back_color)

// modify one of its endpts (.e1 or .e2)

// with the new position

copy_p_3d(oEntity.u.li.e1, oNewSelectedPoint);

//save the modified line in the database

rewrite_ent(&oEntity);

// draw it

draw_ent(&oEntity, oEntity.color);

Link to comment
Share on other sites

Thanks for replying, Pete. It's good to know that there's a now a Developer's forum.

 

I should have pasted my entire code before. I did make a line using oNewSelectedPoint, but the point is not in the desired 3d space. Let's say I was to tweak the endpoint such that the new line is only 5 degrees from the original line. The point_proc() method is giving me a point which 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;

oint_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();

 

}

 

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

 

Should I be converting the new point to View or World coordinates, or is there a different method that needs to be used. Is there a way to do this dynamically?

 

Thanks again Pete.

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