Need help using getToolList function.

Need help using getToolList function.

jackG933P
Contributor Contributor
633 Views
1 Reply
Message 1 of 2

Need help using getToolList function.

jackG933P
Contributor
Contributor

I am trying to edit my post so that I can put more tool data in the tool list at the start of the program. Every post uses getToolTable, but the documentation says that this is deprecated and I should use getToolList. Get tool list seems to output an array of objects in the format { tool:{}, operations:{}, range: {}}. Is there a way for me to export this data as a JSON so that I can look at how to access and manipulate it? I am having issues getting the tool type. I want to display different info based on the tool type, but it's not working. getToolTypeName is the function used to get a readable tool type name, but this is coming up as undefined for every tool and the tool types are not being recognized. I just need to know how this data is stored but I don't have a way of looking at it. Any help is appreciated. 

 

Below is my code for reference:

 

 

 

 

 

 

      var tools = getToolList();

      for(var i=0;i < tools.length; i++){
        var comment = "T" + toolFormat.format(tools[i].tool.getNumber()) + " ";

        if((tools[i].tool.type == 'TOOL_TAP_RIGHT_HAND') || (tools[i].tool.type == 'TOOL_TAP_LEFT_HAND'))
        comment += tools[i].tool.getDescription() + " ";
        else{
          comment += "D=" + tools[i].tool.getDiameter() + " ";

          if((tools[i].tool.type == 'TOOL_DRILL') || (tools[i].tool.type == 'TOOL_MILLING_FACE') || (tools[i].tool.type == 'TOOL_MILLING_RADIUS') || (tools[i].tool.type == 'TOOL_MILLING_SLOT') || (tools[i].tool.type == 'TOOL_MILLING_DOVETAIL') || (tools[i].tool.type == 'TOOL_MILLING_TAPERED') || (tools[i].tool.type == 'TOOL_MILLING_LOLLIPOP') || (tools[i].tool.type == 'TOOL_MILLING_THREAD'))
          comment += tools[i].tool.getDescription() + " ";

          if(tools[i].tool.type == 'TOOL_MILLING_END_BULLNOSE')
          comment += "CR=" + tools[i].tool.cornerRadius + " ";

          if(tools[i].tool.taperAngle > 0)
          comment += "TAPER=" + tools[i].tool.taperAngle + "DEG ";

          comment += tools[i].tool.numberOfFlutes + " FLUTE " + getToolTypeName(tools[i].tool) + " FL=" + tools[i].tool.fluteLength + " SO=" + getBodyLength(tools[i].tool);
        }
        writeComment(comment);
        writeln(JSON.stringify(tools[i].tool.length));
      };
0 Likes
634 Views
1 Reply
Reply (1)
Message 2 of 2

boopathi.sivakumar
Autodesk
Autodesk

You have to pass the type to get the name but you are passing the tool

          comment += tools[i].tool.numberOfFlutes + " FLUTE " + getToolTypeName(tools[i].tool) + " FL=" + tools[i].tool.fluteLength + " SO=" + getBodyLength(tools[i].tool);
        }


The above line should look like this

 comment += tools[i].tool.numberOfFlutes + " FLUTE " + getToolTypeName(tools[i].tool.type) + " FL=" + tools[i].tool.fluteLength + " SO=" + getBodyLength(tools[i].tool);
        }

Boopathi Sivakumar
Principal Technology Consultant

0 Likes