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:

list_manager argument


Recommended Posts

Hi all,

I am porting a Mastercam9 chook to X2 and there is a function list_manager() which has library name as its second argument. What is this library name supposed to be? I have tried "D:MastercamX2MillToolsTools.tools"

"MillToolsTools.tools"

"Tools.tools"

"Tools"

"" - null string

 

where Tools.tools is my tools library and its in "D:MastercamX2MillTools", but this function always gives back NULL pointer that is given as its fourth argument. Following is the code

 

tl_list *tl_head list_manager(TL_ID, "Tools.tools", LSTMGR_GET, (void**)&tl_head);

 

whats wrong? headscratch.gif please help

 

Thank you

Link to comment
Share on other sites

It looks like you're doing it right.

 

Coupla questions...

 

This worked in V9, right?

 

Is 'tl_head' defined as a 'tl_list'?

 

If you run the C-hook from within a session of mastercam where you've already got some operations defined, then the null string should return the tool list of the current part. Could/Did you try that?

Link to comment
Share on other sites

Yes, in V9 this code worked:

 

list_manager(TL_ID, tool_library, LSTMGR_GET, (void**)&tl_head);

 

And tl_head is defined as: tl_list *tl_head;

 

And yes, if I run my C-hook from within a session where some operations are defined then the null string returns the tool list currently used by the operations.

Link to comment
Share on other sites

Hi

 

it just works for me. I'm using list_manager for getting tools and operations.

 

hmm...

 

// "" is cuurent tool library in the database.

list_manager(TL_ID, "", LSTMGR_GET, (void**)&tl_head);

 

// tool_library -> ToolLibraryStr() or ToolLibrary().GetBuffer(0) or "c:mcamx2mill....test.tools" etc..

list_manager (TL_ID, ToolLibraryStr(), LSTMGR_GET, (void **)&tl_head);

Link to comment
Share on other sites

Hi MasterShake,

 

After your post I tried this:

 

SetToolLibrary("MILLTOOLSTOOLS.TOOLS");

list_manager(TL_ID, const_cast(ToolLibraryStr()), LSTMGR_GET, (void**)&tl_head);

 

and it worked, but I don't know why can't the code below work for me?

 

list_manager(TL_ID, "MILLTOOLSTOOLS.TOOLS", LSTMGR_GET, (void**)&tl_head);

 

 

Thank you for giving valuable information.

Link to comment
Share on other sites

Some more info:

 

The code that I said worked is working only after I add some machine and fails if no machine is added and secondly even after I get a pointer in tl_head, the tool parameters are all either zero or garbage values. It seems the memory location being retured in tl_head is not correct.

Link to comment
Share on other sites

BijuGeorge,

 

Your observation that this is dependent upon the presence of a current Machine Def is valid. This function will not work when you are in 'design' mode.

 

The following works for me and the tool parameters look pretty good as I cycle through them...

 

 

extern "C" int __declspec( dllexport ) m_main(int i)

{

AFX_MANAGE_STATE( AfxGetStaticModuleState() );

 

CString toolLibname = "c:McamxX2_MR1MillToolsMILL_INCH.TOOLS";

tl_list *tl_head=NULL;

list_manager(TL_ID, toolLibname.GetBuffer(0), LSTMGR_GET, (void**)&tl_head);

tl_list *tl = tl_head;

while(tl)

{

tl = tl->next_ptr;

}

return 0;

}

 

 

I'm wondering now about 'byte-packing'. Are you compiling your X (or X2) version with /Zp8? if you look in your Project's properties under C++/CodeGeneration, make sure "Struct member alignment" is set to '/Zp8' or 'Default'. In the V9 world, we required /Zp1, but that'll mess you up in X.

Link to comment
Share on other sites

Pete,

 

Thank you so much for your elaborate replies. Well, the code you've written works for me too now(only after choosing some machine from 'Machine Type' menu). The change which I made after which the code started working was that I made a new C-Hook project and copied the old files from the previous one. I guess my project was being linked to old sdk because there were files of old sdk littered around in the previous version of the project.

 

Thanks

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