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:

Chain Function in Chook


CAM Disciple
 Share

Recommended Posts

I am trying to create my own chook to accomplish this task.

 

I have a square shape in my drawing. I had created my own math function to obtain all the end points, vector, and also the center point of the square. However, I am confused at this point as to how to create a contour tool path of this square using Chook.

 

I have the following questions:

1) Do I need to create a chain first in order to generate a contour toolpath? Can I generate the contour toolpath based on all the end points of the square?

 

2) In the chain header file: m_chain.h

code:

  short chain_it(

char txt_hrd[]

short msg_n,

CHAIN **chains);

Is this function used for selecting a point and then create a chain?

I am not familar with CHAIN **chains declaration... it appears to me that it's asking for a pointer to a pointer of chain structure. How do you use it?

If I have a public variable call CHAIN myChain... do I use the chain it function like this:

returnVal = chain it(txt1,msg1,&myChain)

 

3) What's the logical step of creating a toolpath?

Was it like this:

a) use operation_manager to create an operation

B) create a chain

c)use chain manager to add the chain to the operation

 

If I use operation_manager to create a toolpath, do I need to do anything else such as setting NCI file?

 

Please help. Thank you

 

[ 12-24-2003, 11:36 PM: Message edited by: CAM Disciple ]

Link to comment
Share on other sites

Bryan,

 

This works for me:

 

code:

	CHAIN_ENT newChainEnt;

CHAIN *chain1;

CHAIN chain2;

chain_manager_info cmi;

alloc_chain(&chain1, FALSE);

chain_1(TXT_HDR,2,&chain1);

chain2 = *chain1;

newChainEnt = *chain1->start;

chainEntPtr = newChainEnt.e_ptr;

memset (&op, 0, sizeof (operation));

op.opcode = TP_CONTOUR;

strcpy(op.comment,"Add Chain to toolpath");

operation_manager (&op, OPMGR_INIT_ADD, &d_ptr, &succf);

if (!suppress_error && !succf) return;

op.cc.type = CC_CONTROL;

op.cc.direction = CC_LEFT;

op.misc.on = TRUE;

operation_manager (&op, OPMGR_EDIT, &d_ptr, &succf);

memset (&cmi, 0, sizeof (chain_manager_info));

cmi.op_idn = op.op_idn;

cmi.mode = CHNMGR_ADD;

cmi.chns = chain1;

chain_manager (&cmi, 0, &succf);

if(succf == FALSE)

mprintf("nToolpath generating failed");

 


But still, would love to just past the an entity to create a chain instead of asking a user to select a point then use the chain manager.

 

Bryan, do you have any ideas or light bulb that I can share with you? wink.gif Thanks

Link to comment
Share on other sites

No ideas here. I can create/import toolpaths no problem. I can search through the entities no problem. But when I try to add say 4 lines or arc(s) I get horible crashes. Obviously, I'm doing something wrong and the sdk documentation is nonexistant. I was hoping someone from CNC would post code with the proper steps.

 

PDG? Mick? Bulliness? Anybody?

 

Bryan smile.gif

Link to comment
Share on other sites

CAM,

 

I need to do both. I need to add 1 to many full arcs to a contour. And in another contour I need to add several lines as 1 chain to a contour.

 

chip,

 

If your talking about chooks look at op_lead_io in M_ATYPES.H it has

boolean enter_at_midpt; // TRUE = enter at midpoint of first entity for closed contours

 

set that to TRUE, rewrite the op, and regen.

 

Bryan smile.gif

Link to comment
Share on other sites

I was thinking of 'A' c-hook function. I usually can't get Chain endpoint midpoint. Usually I get near where I want the chain to start W/ dynamic.

 

i.e. I'm cutting a spline (looks similar to hambuger bun.) If I could run a c-hook to chain and start in a specific place, due to islands on either side that would make me happy! Instead of breaking or adjusting dynamically a few times.

 

Brian, I've seen your web page, You program c-hooks quite well.....

Link to comment
Share on other sites

PDG,

 

Thanks. You're my Hero. biggrin.gif

 

I think I see what I was doing wrong now.

 

 

2 questions.

 

What is checkEntAgainstChain looking for? That the entity is already present in the chain so there are no duplicates? Or something more, like matching up endpoints on entities?

 

Second, the function addedCandidate is that just (re)setting something for the getACandidate function? Or is it doing something more?

 

Bryan smile.gif

Link to comment
Share on other sites
  • 9 months later...

^^bump^^

 

I have the same question about checkEntAgainstChain() in the FTP document you uploaded PDG.

 

I'm using that code, word for word, but my chains will not connect. For example, I have an arc, an adjacent spline, and another arc adjacent to the spline. The spline connects the arcs and it forms one smooth line. However, they will not chain together.

 

When I call draw_chain_direction() I can clearly see all 3 arrows for what appears to be 3 seperate chains.

 

What does not get called, is the append_chain() function. After set_chain_closed() is called, the following condition is never true.

 

I wrote checkEntAgainstChain(). It looks at the entity.id, and gets the index 0 or 1 of the closest point to the point returned by get_end_point() on the chain.

 

On a different but related topic. If you colorize arcs, splines, etc. and manually use the mouse to create a chain with the color mask set to true, it grabs up all 3 entities and chains them. Is there a way to excercise this color flag in the SDK? I tried setting it to true and making a chain, and it did not have the same effect of grabbing all the adjacent same color entities. Am I missing something?

 

Sincerest thanks,

 

Robert

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