100% found this document useful (1 vote)
1K views267 pages

Post Building Techniques NX8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views267 pages

Post Building Techniques NX8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 267

Post Building Techniques

Student Guide
October 2011
MT11060 — Post Builder 8.0

Publication Number
mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Proprietary and restricted rights notice

This software and related documentation are proprietary to Siemens Product


Lifecycle Management Software Inc.
© 2011 Siemens Product Lifecycle Management Software Inc. All Rights
Reserved.
Siemens and the Siemens logo are registered trademarks of Siemens AG.
NX is a trademark or registered trademark of Siemens Product Lifecycle
Management Software Inc. or its subsidiaries in the United States and in
other countries. All other trademarks, registered trademarks or service
marks belong to their respective holders

2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Contents

Proprietary and restricted rights notice . . . . . . . . . . . . . . . . . . . . . . 2

Course overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Course objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
How to use this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Lesson format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Learning tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Classroom system information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

The NX Post postprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1


Postprocessing in NX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
NX Post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Manufacturing Output Manager (MOM) . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Using Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Summary: The NX Post postprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8

Build a postprocessor with Post Builder . . . . . . . . . . . . . . . . . . . . . 2-1


Files created by Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Activity: Classroom preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
NX/Post Builder dialog box overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Defining a new postprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Define a new main post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Add a new post to the NX menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Activity: Introduction to Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Defining and editing main post processors . . . . . . . . . . . . . . . . . . . . . . 2-11
Machine Tool tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
General parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Mill specific parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
Activity: Machine tool parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Program & Tool Path tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Activity: Word summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
Program & Tool Path tab continued . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
The Program tab interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
Program tab — program sequence structure . . . . . . . . . . . . . . . . . . . . . 2-24
Using the Program tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
Activity: Program and tool path parameters . . . . . . . . . . . . . . . . . . . . . 2-27
NC Data Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28

Post Building Techniques – Student Guide 3


Contents

Block tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30


Word tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Format tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
Activity: NC Data Definitions tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40
Create new M or G code groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
Activity: Create a new group of coolant codes . . . . . . . . . . . . . . . . . . . . 2-42
Output Settings tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
Listing File tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Other Options tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
Activity: Output settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50
Post Files Preview tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51
Post Files Preview property page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52
Summary: Build a postprocessor with Post Builder . . . . . . . . . . . . . . . . 2-53

Units-only subposts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1


Defining and editing units-only subposts . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Activity: Create a units-only subpost . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Summary: Units-only subposts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5

Post Builder for Wire EDM applications . . . . . . . . . . . . . . . . . . . . . 4-1


Creating 2-axis and 4-axis wire EDM postprocessors . . . . . . . . . . . . . . . . 4-2
Wire EDM specific parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Activity: Create a 2-axis Wire EDM post . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Summary: Post Builder for Wire EDM applications . . . . . . . . . . . . . . . . . 4-5

Post Builder for 4-axis and 5-axis mills . . . . . . . . . . . . . . . . . . . . . . . 5-1


Creating 4-axis and 5-axis mill postprocessors . . . . . . . . . . . . . . . . . . . . 5-2
Mill Fourth Axis and Fifth Axis parameters . . . . . . . . . . . . . . . . . . . . . . 5-3
Rotary Axis Configuration dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Activity: Create a 5-axis Mill post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9
Summary: Post Builder for 5-axis mills . . . . . . . . . . . . . . . . . . . . . . . . . 5-10

Post Builder for lathe applications . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1


Creating lathe postprocessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
2-axis lathe-specific parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Activity: Create a lathe post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
Summary: Post Builder for lathe applications . . . . . . . . . . . . . . . . . . . . . 6-6

Create Mill-Turn postprocessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1


Create a mill-turn post . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Activity: Create a Mill-Turn postprocessor . . . . . . . . . . . . . . . . . . . . . . . 7-3
Define heads for mill-turn centers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Activity: Create a 5-axis multi-link mill-turn post . . . . . . . . . . . . . . . . . . 7-6
Summary: Create Mill-Turn postprocessors . . . . . . . . . . . . . . . . . . . . . . 7-7

4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Contents

Tcl basics for Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1


Tcl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Tcl command structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Tcl variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Value of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Scope of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
Arrays of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
Working with variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
Additional variable substitution examples . . . . . . . . . . . . . . . . . . . . . . 8-11
Determining set variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
Tcl control of word structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
Tcl special characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
Tcl mathematical expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
Activity: Tcl basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Tcl scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Tcl procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
Explicitly returning a value from a procedure . . . . . . . . . . . . . . . . . . . . 8-22
Intermediate-level use of the return command . . . . . . . . . . . . . . . . . . . 8-22
Basic error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23
Tcl input and output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24
Working with files in Tcl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
Tcl string commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-37
Activity: Construct a simple procedure . . . . . . . . . . . . . . . . . . . . . . . . . 8-40
Program flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41
Activity: Program flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-49
Regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-50
Tcl and NX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-53
Tcl reference manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-54
Summary: Tcl basics for Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . 8-55

Custom commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1


Custom Command tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Importing custom commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
Activity: Custom commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
Summary: Custom commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6

User defined events and user defined cycles . . . . . . . . . . . . . . . . . 10-1


User-defined events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
User Defined Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5
User-defined event .cdl file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6
Keywords in the .cdl file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
Enabling the UDE Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
Create a UDE or UDC in Post Builder . . . . . . . . . . . . . . . . . . . . . . . . 10-10
Create an event handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11
View event handler Tcl code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13

Post Building Techniques – Student Guide 5


Contents

View an event in the .cdl file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14


Add user defined events to the NX Manufacturing environment . . . . . 10-15
UDE dialog box graphic requirements . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Activities: User defined events and user defined cycles . . . . . . . . . . . . 10-19
Summary: User-defined events and user-defined cycles . . . . . . . . . . . . 10-20

Virtual NC controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1

Integrated simulation and verification overview . . . . . . . . . . . . . . . . . . 11-2


Machine Tool Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
VNC work flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
Activity: Use Post Builder to create a VNC . . . . . . . . . . . . . . . . . . . . . . 11-7
Axes, junctions, and zero reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
Summary: Virtual NC Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11

Postprocessing with a Siemens controller . . . . . . . . . . . . . . . . . . . 12-1

Sinumerik template posts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2


Events and cycles for Sinumerik controllers in NX . . . . . . . . . . . . . . . . 12-3
Procedures and settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
Activity: Postprocess with a Siemens controller . . . . . . . . . . . . . . . . . . 12-6
Summary Siemens controller support . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7

Create a macro with Post Builder . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1

Macro tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2


Activity: Create a macro with Post Builder . . . . . . . . . . . . . . . . . . . . . . 13-5
Summary: Create a macro with Post Builder . . . . . . . . . . . . . . . . . . . . 13-6

Project activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1

A guide to best practices of building a postprocessor . . . . . . . . . . A-1

Appendix: Checklist of information . . . . . . . . . . . . . . . . . . . . . . . . B-1

Appendix: Supermill technical document . . . . . . . . . . . . . . . . . . . C-1

UGS Supermill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-2


Milling options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-5
Tool Length pre-setting options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8
Chip Conveyor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-9
Dust removal system (vacuum) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-10
Measurement options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-11
Specialized application software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-12
Supermill CNC options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-13
Programming functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-14
Milling accessories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-18
Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-19

6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Contents

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index-1

Post Building Techniques – Student Guide 7


Course overview

The Post Building Techniques course acquaints users with tools and
techniques that are used for building custom, machine tool specific post
processors using the Post Builder application. For those post processors that
cannot be fully developed using the Post Builder application, methods are
shown for customizing and modifying the definition and event handler files,
used by NX Post for specific needs.

Intended Audience
This course is suited for designers, engineers, manufacturing engineers,
application programmers, NC programmers, CAD/CAM managers, and
system managers who have a need to build posts for NC programming.

Course objectives
After successfully completing this course, you will be able to:
• Build a postprocessor with Post Builder.

• Define a units-only subpost for existing postprocessors.

• Create an M-Code group.

• Create posts Wire EDM, 5-Axis Mill, Lathe, and Mill Turn machines.

• Make basic Tcl edits.

• Create user-defined events (UDE) and user-defined cycles.

• Use Post Builder to create a virtual NC controller (VNC).

Post Building Techniques – Student Guide 9


Course overview

Prerequisites
Required courses
• NX Manufacturing Fundamentals

Working knowledge of the following:


• Fixed and Multi-Axis Machining, or Turning Manufacturing Process.

• A thorough understanding of NC/CNC programming principles and a


thorough understanding of NC/CNC machine/controller functionality.

• Successful completion of Essentials for Designers, or prerequisite


assessment on Learning Advantage site (score >70%). Learning
Advantage courses can also be used to prepare for the prerequisite
assessment.

• An understanding of basic programming principles such as conditional


statements, variables, and procedures is needed to be successful with
postprocessor customizing, although not required for the class. Familiarity
with the Tcl language is recommended, but not required.

10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Course overview

How to use this manual


The following guidelines describe how you can get the most benefit from your
use of the course guide and the accompanying HTML activities.

Lesson format

The general format for lesson content is:


• Instructor presentation

• One or more activities

• Project
Projects allow you to test your new skills without detailed instruction.
Consult your instructor for additional information.

• Summary

Learning tips

• Ask questions.

• Take notes.

• Confirm important facts by restating them in your own words.

Because later lessons often build on functionality taught in earlier


lessons, it is important that you follow the lessons in the sequence in
which they appear in the Student Guide.

Post Building Techniques – Student Guide 11


Course overview

Classroom system information


Your instructor will provide the following items for working in the
classroom:

Student login:
User name:

Password:

Work directory:

Parts directory:

Instructor:

12 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
1
Lesson

1 The NX Post postprocessor

Purpose
This lesson describes the postprocessing function of NX and the various
components of a postprocessor. An overview of the Post Builder module
is also presented.

Objective
Upon completion of this lesson, you will be able to:
• Understand the terminology and interrelationships of the various
components of NX Post.

• Understand the use of the Post Builder as a tool to build postprocessors.

Post Building Techniques – Student Guide 1-1


The NX Post postprocessor

1
Postprocessing in NX
Each machine tool and controller combination has different requirements,
for example tool change commands, specific M-codes and G-codes, and the
sequence of G-codes that is permitted in a program line.
Postprocessing is the process of outputting machine code so that your tool
path is recognized by a machine tool and controller combination. Before you
can postprocess a tool path in NX, you must create the tool path in NX and
create an appropriate post processor in NX Post Builder.
A tool path consists of the following:
• Information about tool motion, such as GOTO points and feed rates.

• Instructions to the controller, for example, coolant and spindle control,


called events.

The NX postprocessor, referred to as NX Post, consists of the following:


• Instructions to generate code words that control the machine tool’s
response to events.

• Definitions of how to sequence and format the output words.

• Instructions to Post Builder so that can recreate the graphic interface for
your post when you edit it.

1-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
The NX Post postprocessor

1
NX Post
NX Post is a set of programs and files that you use in the Manufacturing
application to post process NX tool paths with posts define by the NX Post
Builder.
You can start NX Post by the following means:
• Right-click a selected program or operation nodes in the Operation
Navigator and choose Post Process.

• Select one or more programs or operations and click Post Process


on the Operations toolbar.

NX Post uses tool path data as input, and outputs machine controller
readable CNC code. You can customize your postprocessors in several ways
to generate the output that you require for several supported machine tool
categories, including the following:
• Mills

• Lathes

• Production Centers, or machines that both turn and mill

• Wire EDM machines

The extensibility of NX Post processors is achieved through the scripting


language Tcl and the use of definition files.

Post Building Techniques – Student Guide 1-3


The NX Post postprocessor

1
The following flowchart illustrates the steps required to postprocess tool path
data in an acceptable format for a machine tool and controller.
NX Post architecture

Format definition file — .def


NX tool path data
element of post processor
.pui element of post processor —
Event generator
used only when you edit the post
NX Post and Manufacturing Tcl procedure library —
Output Manager (MOM) ugpost_base.tcl
Output — typically, .ptp machine
Event handler — .tcl element of
tool executable file and optional .lst
the post processor
listing file

The event generator, event handler, and the definition file are interdependent.

1-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
The NX Post postprocessor

1
Manufacturing Output Manager (MOM)
The Manufacturing Output Manager, or MOM, is a utility program used by
NX Post to use tool path data to generate output. NX Post uses the MOM to
do the following.
• Start the interpreter.

• Add data and specify functions to the interpreter.

• Load Event Handlers.

• Load Definition files.

Post Building Techniques – Student Guide 1-5


The NX Post postprocessor

1
Using Post Builder
Post Builder is an application that provides a graphical user interface for
building posts.
Post Builder allows you define many aspects of output, including the following:
• Types of output blocks and word addresses.

• Sequence of output for the following:


o Start of program

o Start of operation

o End of operation

o End of program

o Tool changes

o Canned cycles

One of the outputs of the Post Builder program is a Tool Command Language
(Tcl) script file. With knowledge of the Tcl language, you can extensively
customize Tcl scripts.
Post Builder currently configures postprocessors for the following:
• 3-axis milling machines

• 3-axis mill-turn centers (XZC)

• Multi-axis mill-turn centers

• 4-axis milling machines with a rotary table or a rotary head

• 5-axis milling machines with dual rotary heads or rotary tables

• 5-axis milling machines with rotary head and rotary table

• 2-axis lathes

• 2 and 4-axis Wire EDM machines.

A controller library is provided, with support for several popular controllers,


including Siemens Sinumerik controllers.

1-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
The NX Post postprocessor

1
The following flowchart illustrates the process of building a postprocessor
using Post Builder:
Post processor development process

Gather machine tool specifications


and controller parameters from Test the postprocessor output
manufacturer manuals
Deliver the functional post
Enter parameters in Post Builder
processor

Post Building Techniques – Student Guide 1-7


The NX Post postprocessor

1
Summary: The NX Post postprocessor
In this lesson you were introduced to:
• Post processing with NX Post.

• The function of NX Post components.

• Relationships between NX Post components.

1-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Lesson

2 Build a postprocessor with


2
Post Builder

Purpose
This lesson describes the procedures of building postprocessors through the
use of the Post Builder .

Objective
Upon completion of this lesson, you will be able to:
• Understand the various components of Post Builder.

• Use Post Builder to build a 3-axis mill postprocessor.

Post processor development process

Gather machine tool specifications Test output


and controller parameters from
manufacturer manuals.
Enter parameters in Post Builder. Functional post processor.

Post Building Techniques – Student Guide 2-1


Build a postprocessor with Post Builder

Files created by Post Builder


By default, Post Builder creates all related files for your postprocessor in the
directory where you started Post Builder.
2 To use your postprocessor from the menus in NX you must add an entry to
your template_post.dat file in your current postprocessor directory.
You can modify and verify example posts for your specific needs. You must
obtain a WebKey user name and password to access the sites:
http://ftp.ugs.com/unigraphics/pb_posts/

http://webtest.industrysoftware.automation.siemens.com/
WebkeyLogin/Authenticate2?url=http://plmwebtest.industrysoftware.
automation.siemens.com/postcatalog/index.jsp

Files always created


Post processors that you create with Post Builder have three main files. If
your postprocessor name is my_machine_tool, the files created when you
save your post are as follows:
my_machine_tool.pui
Contains information needed to create the .tcl file. This file must be
present in the same directory as the .tcl and .def files and is refereneced
when you edit your postprocessor.
my_machine_tool.tcl
NX Post uses this Tcl-language file to generate NC code blocks for events.
my_machine_tool.def
This file defines machine tool information such as word formats,
addresses, and NC blocks. NX Post uses this file to format the output for
events that are processed in the Tcl file.

2-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Other files
my_machine_tool.cdl
Appears when you create a user-defined event or a user-defined cycle.
Contains the definition of a dialog box that appears when you add the 2
event from NX. The dialog box is used to gather user input parameters to
control your event or cycle.
my_machine_tool_vnc.tcl
Appears when you select the option to create a virtual NC controller or
VNC.
Contains the Tcl code needed to support simulation using machine tool
driver (MTD) Tcl-based simulation.

Post Building Techniques – Student Guide 2-3


Build a postprocessor with Post Builder

Activity: Classroom preparation


For the activities in this course, you will use a copy of the CAM folder where
postprocessor-related files are stored.
2 You can experiment with Post Builder with no worries about write access
or of corrupting system files.
The following activity in the Build a postprocessor with Post Builder section
will guide you through copying the folder from its installed location to your
home folder:
• Classroom preparation

2-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

NX/Post Builder dialog box overview


Use the NX/Post Builder dialog box to do the following:
• Define a new post processor in the Create New Post Processor dialog box.
2
• Edit an existing post processor.

• Manage the available forms of help for the other dialog boxes.

The dialog box contains only a menu bar, toolbar, and a cue line. Other dialog
boxes appear as you perform tasks related to post processor definition.
When you open the Create New Post Processor dialog box or the editing
dialog box, the cue line continues to show suggestions about the task related
to the page that you are displaying in the other dialog boxes.

Where do I find it?

Start®All Programs®Siemens NX 8.0®Manufacturing


Menu Tools®Post Builder

Post Building Techniques – Student Guide 2-5


Build a postprocessor with Post Builder

Defining a new postprocessor


Use the New command in the Post Builder application to define the following:
• The name and description of your new post processor.
2
• The type of post to be created: Main Post or Units Only Subpost

• The default output units

• The type of machine tool for which the post is intended

• The controller information

You can also choose to enable the user defined event editor and user cycle
editing by default anytime the post is opened for edit.

2-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Define a new main post

1. In the NX/Post Builder dialog box, click New .

2. In the Create New Post Processor dialog box, select Main Post. 2
3. Under Machine Tool, select the type of machine.
For example, you can select Mill for any supported milling machine.

4. Specify the configuration for your machine tool.


For example:
If the machine is a mill, you could select 4–Axis with Rotary Head.
If the machine is a lathe, the only option is 2–Axis.
If the machine is a wire EDM, you could select 4-Axis.
After you click OK in this dialog box, you cannot change the machine
type for the post processor.

5. (Optional) Modify the default description to describe your machine tool


in greater detail.
You can access the description by choosing File®Post Properties in the
NX/Post Builder dialog box while the post processor is open for editing.

6. In the Name box, type a name for your post processor.


You can also temporarily accept the default name, new_post, and assign a
name the first time you save the post processor.

7. Specify the default output units.


You may find it convenient to use the units presented in the machine
manual. For example, if values in the manual are in inches, you can
define the machine using inch values.
After you save the post processor, you can create a units-only subpost to
output millimeters.
If a millimeter subpost is defined and linked to an inch post processor, it is
used automatically whenever millimeter output is required.

8. Click OK to create the post processor in computer memory and open it


for edit.

Post Building Techniques – Student Guide 2-7


Build a postprocessor with Post Builder

Add a new post to the NX menu


You can always browse to your post in NX. If you use a post frequently,
you can add it to the list of available postprocessors that appears in the
Postprocess dialog box in NX, and you can position it in the list, using the
2 Edit Template Posts Data File dialog box.
1. In the NX/Post Builder dialog box, choose Utilities®Edit Template Posts
Data File.

2. In the Install Posts dialog box, make certain that the path in the Template
Posts Data File box points to the template_post.dat file that is in the
folder pointed to by your UGII_CAM_RESOURCE_DIR variable.

If the path is not correct, click Browse and navigate to the correct file.

3. In the editing window, select the post before which you want your new
post to appear.

4. Click New.

5. In the Open dialog box, navigate to your new post, select it, and click
Open.

2-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

6. (Optional) If you want to reorder the list of posts, use the Cut and Paste
buttons.
When you paste a line, it is always inserted before a selected line in the
file.
2
The Edit button allows you to modify the path and file name of a post
entry in the list of available post processors. Use it only if you have
renamed or moved a post.

7. Click OK to save and close the edited file..

Post Building Techniques – Student Guide 2-9


Build a postprocessor with Post Builder

Activity: Introduction to Post Builder


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • Introduction to Post Builder

2-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Defining and editing main post processors


The dialog box to define and edit a post processor shows the name of the
currently open post processor in its title bar.
The following main tabs are available: 2
Machine Tool Lets you display a generic view of the machine tool, set
basic kinematic parameters of the machine tool, and
set or modify some basic controller capabilities, such as
whether to output circular records.
Program & Tool Lets you add code blocks and words, set the format and
Path sequencing for controller words, managed linked posts,
and more.
N/C Data Lets you modify blocks, words, formats, and word formats;
Definitions attach user defined event files; and inherit user defined
events from other posts.
Output settings Lets you manage listing file output and listing file
content, attach units-only subposts, and more.
Virtual N/C Lets you configure a virtual numeric controller. Output is
Controller compatible only with the Tcl-based machine tool driver,
or MTD.

Post Building Techniques – Student Guide 2-11


Build a postprocessor with Post Builder

Machine Tool tab


The Machine Tool tab has options that allow you to configure the kinematics
of your machine tool. You can define the limits and direction of axis
movements, orientations where applicable, axis multipliers, traversal feed
2 rate, and so on.
The machine tool configuration tree can be divided in as many as 3 sections,
depending on the selected machine tool configuration.
Configuration Available for…

General
Parameters All machines
4-axis and 5-axis
Fourth Axis mills
Fifth Axis 5-axis mills

Default and Restore


The Default button returns you to the state when the post was last saved for
the current tab.
The Restore button returns you to the state when you entered the current tab.

2-12 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

General parameters
The following options are available for all machine types.

Display Machine Tool 2


Click Display Machine Tool to visualize an approximation of your machine
tool. You can verify axis orientations. For a four and five axis milling machine
you see the address designation, A, B or C, and the current limit settings
for each rotary axis.
Pictures are not available for mill-turn and wire-EDM configurations.

Output Circular Record


You can set this option to Yes or No. If set to Yes, the system outputs all
circles based on the circle motion parameters. If set to No the system does
not output circle blocks (G2 or G3).
Circular record output also depends on the Default Coordinate Mode and
Circular Record Mode settings.
Default Coordinate Mode Circular Record Mode
Output
setting setting
Polar Polar Polar circles
Cartesian Cartesian Cartesian circles
Cartesian Polar No circle output
Polar Cartesian No circle output

Linear Axis Travel Limit


This option allows you to check travel limits when you import the custom
command pb_cmd_check_travel_limits.tcl.

Home Position
This defines the default FROM position if you have not specified a FROM
position.

Linear Motion Resolution


This defines the minimum value to which the system rounds all coordinates.
This does not necessarily control the format of the coordinate data. To control
the format of the coordinate data you must change the number of decimal
digits output.

Post Building Techniques – Student Guide 2-13


Build a postprocessor with Post Builder

Traversal Feed Rate


This defines the feed rate that the system uses to calculate machine time for
rapid motion. The system also uses this value to determine if a linear feed
rate move is actually performed at rapid.
2

2-14 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Mill specific parameters

Axis Multiplier
Use Axis Multiplier with diameter programming for mill-turn postprocessors. 2
Diameter Programming
Use Diameter Programming to multiply the X and I words by two, so that
they represent diameter instead of radius.

Mirror X axis
Use Mirror X axis to program your part in the fourth quadrant and output it
in the first quadrant. X and I words are multiplied by minus one.
Use Mirror Z axis to multiply the Z and K words by minus one.

Initial Spindle Axis


Specify a value for Initial spindle Axis to set the default spindle axis, which
determines the initial work-plane of the machine tool.

Post Building Techniques – Student Guide 2-15


Build a postprocessor with Post Builder

Activity: Machine tool parameters


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • Machine tool parameters

2-16 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Program & Tool Path tab


The Program &Tool Path tab has options that allow you to determine the NC
output for specific events and commands that are generated by the NX Event
Generator. The tabs under this option control the content, format and order
of output for your NC Code.
2

Use the Program and Tool Path tab to create, modify, and customize of event
handlers.
The Program and Tool Path tab is divided into the following tabbed pages:
Program
Lets you create, modify, or customize program start sequences, operation
start sequences, tool path events including machine control events, motion
events, canned cycles events, operation end sequences and program end
sequences.
G Codes
Lets you specify G-codes throughout the postprocessor. Changing any
G-code in this list updates the G-code globally.
M Codes
Lets you specify M-codes throughout the postprocessor. Changing any
M-code in this list updates the M-code globally.
Word Summary
Lets you modify groups of words that have the same format, such as G17,
G18, and G19, or X, Y, and Z.
To specify a different format for only one word in a group, use the Format
tab on the NC Data Definitions tab.
The following parameters appear on the Word Summary tab:
Word
Contains the system’s symbol for the word. This name is the same
name that you find in the word address section of the N/C Data
Definitions section.

Post Building Techniques – Student Guide 2-17


Build a postprocessor with Post Builder

Leader/Code
Lets you modify the leader for any word. The leader is the character
than precedes the numeric information. For instance, if the word is
X12.345, then the leader is X. You can either type in a new leader or
2 right click on the existing leader and choose from the list.

Data Type
Lets you specify numeric or text. Usually NC code is numeric. Specify
text when the code you need cannot be formatted from a number
directly into a word address and a value. For example, if you need a
G84.1 for tapping and G81 (without a decimal) for drilling. In this case
you have to make the G_motion word text, and change all the G codes
to G81 as text, instead of the number 81 with G as the leader. You
can use the Format tab on the N/C Data Definitions tab to make the
change.
Plus (+)
Lets you output a plus sign for all positive numbers. If you set
this option to No you get an X1.0. If you set this to yes, you get an
X+1.0. You always get a minus sign for all numeric data if the specified
number is negative.
Lead Zero
Lets you define whether or not you output leading zeroes with your
N/C Code.
Integer
Controls the number of digits that are output to the left of the decimal
point. You get an error if your numeric data exceeds the format you
have specified.
Decimal (.)
Controls whether or not numeric data is output with a decimal
point. You get an error if you suppress the decimal point and do not
output at least leading or trailing zeroes.

2-18 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Fraction
Determines how many digits are output to the right of the decimal
point.
Trail Zero 2
Lets you define whether or not you output trailing zeroes with your
N/C Code.

Post Building Techniques – Student Guide 2-19


Build a postprocessor with Post Builder

Activity: Word summary


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • Word summary

2-20 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Program & Tool Path tab continued


Word Sequencing
Lets you customize the output order of controller words. For example, if
you exchange the X and Y words, all blocks generated by all events reflect 2
the change. You can also suppress or make any word active.
If Balloon Help is active, each word displays its context in the balloon help.
A representative code is used to display word groups. For example, the
G17 word also represents the sequencing of G18 and G19.
Custom Command
Lets you add user-created custom commands as Tcl procedures that you
can place with any event marker in the post. With syntax checking set
to on, you cannot create a Tcl procedure that is syntactically incorrect;
however, there is no checking of details within custom procedures. Several
useful custom commands are provided with your default post. You can
import additional custom commands from a library of custom commands.
Numerous custom commands, designed for common special applications,
are supplied with every release of Post Builder.
When you create a custom command, the software places the correct
syntax around the body of the procedure that you are creating. The first
line of the Custom Command is:
proc PB_CMD_name_of_proc {} {

The content goes between the braces, and the last line shows the closing
brace:
}

Custom procedures are processed in the sequence where you place them.
Linked Posts
Lets you specify posts that can be linked to your current post. Linked
posts are used in situations where separate posts have been developed
for special machine options such as right angle milling heads, specialized
mill-turn centers, machining centers having more than two rotary axis or
any application that requires multiple Postprocessors.
You need to assign a HEAD UDE to the program or method group that
indicates the post to be used to process the head. There is a table where
you can specify a minor word after the HEAD command, or head name,
to identify the post.

Post Building Techniques – Student Guide 2-21


Build a postprocessor with Post Builder

Macro
Use this tab to create, edit, or remove block templates for making calls to
macro, cycle, or functions in the NC program.

2 The output codes are in the form of cycle or macro calls, such as
CYCLE81(...) for the Sinumerik 840D controller or CYCLE DEF 204 A200=...
for the Heidenhain iTNC530 controller, or other similar high level
function calls.

2-22 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

The Program tab interface


When you select a sequence on the left, the parameters associated with the
sequence are is displayed on the right.
2

Program sequence tree Sequence marker


Add Block Sequence blocks
Display Combined N/C Code Normal block
Blocks MOM command or custom
New block command
Operator message
Trash can
Custom macro

Blocks with a light blue background, like PB_CMD_tool_change_force_addresses


in the graphic, are used by more than one marker. Changing one instance
affects all instances of the block.
Blocks with a white background are used only once in the post.

Post Building Techniques – Student Guide 2-23


Build a postprocessor with Post Builder

Program tab — program sequence structure


Due to the way that tool paths are created in NX, certain events, such as tool
change, spindle start, or approach motion events, can occur at the start and
end of an NC program and for each operation.
2
Understanding the sequences and the events that trigger them allow you to
properly place custom commands and blocks to obtain the desired output.
At the markers of these predetermined events, designated by yellow
rectangular blocks, you can force instruction blocks to be output. This output
combination is referred to as a sequence.
The program sequence tree contains the following:
Program Start Sequence
Determines the code blocks that are output when the program start event
occurs, before any other event is processed.
Operation Start Sequence
Determines events and actions that will occur from the start of an
operation to the first cut motion.
Every operation has one of the following: first tool change, automatic tool
change, manual tool change, or no tool change.
Tool Path Sequence
consist of Events and actions that pertain to machine control, motion
control and canned cycles.
You cannot drag new blocks into tool path sequences.
Machine Control
Controls machine tool features such as coolant, spindle, tailstocks
and clamps.
Can also be used to change modes such as incremental or absolute,
inverse time, feed per minute or per revolution and constant surface
speed.
You can pass information to a postprocessor by parameter data which
is available at the Start of Operation marker. This includes feeds and
speeds and any cutting parameters such as stepover and tolerances.
You can pass information within this and other tool path sequences
by User Defined Events, or UDEs, which are sometimes called post
commands. UDEs specified as Start of Post come out after the Start of
Operation event in the order specified by operation markers, where
markers indicate events that may occur. UDEs associated with the
tool, program, method, or any other parent group are output before
the Start of Operation event. The recommended method of output
for start of operation NC code is to organize all of the data, such as

2-24 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

spindle speed, spindle direction, coolant status, length compensation,


and tool number, and then output this data as part of the Operation
Start Sequence.
Motion
Controls how the postprocessor processes GOTO records in the tool path.
2
Motion types included in this event type are cut, engage, first cut,
stepover and side cut. Circular motion is handled by the Circle Move
Event. An event type for Nurbs is currently handled by the Post
Builder for Fanuc 6M, Siemens and Heidenhain controls.
Canned Cycle
Describes how the postprocessor handles canned cycles. You can define
or modify the G-code, associated parameters, and output blocks that
are used with pre-defined cycles, or, if UDE editing is enabled, you can
create a used-defined cycle by right-clicking the background.
Miscellaneous
Controls suboperation start and end events.

Operation End Sequence


Contains events and actions that occur from the final retract motion to the
end of the operation. These are items like returning to a home position
or turning off the spindle and or coolant. If the same End of Operation
function is always going to be performed at the end of every operation you
can enter it into this sequence instead of programming UDEs.
Program End Sequence
Contains events and actions that occur from the end of the last operation
to the end of the program.

Post Building Techniques – Student Guide 2-25


Build a postprocessor with Post Builder

Using the Program tab


You can drag Add Block to add an available block selected in the list
to the location where you want the output. You can place it above, below or
2 next to an existing block component.
Selecting the Display Combined N/C Code Blocks check box displays all
block components in the form of NC codes. By default, block components are
displayed showing their descriptions.
The Add Block component list shows available blocks. You can create a new
block component and apply it to a sequence. You can also select one of the
predefined block components.

To use the trash bin, drag an unwanted block to the trash bin icon.
You can also delete the component by right-clicking it and choosing Delete.
You can neither add or delete event blocks. You can create user-defined events.
If you right-click the block component, a shortcut menu appears which allows
you to perform the following actions:
• Cut

• Copy As

• Paste

• Delete

2-26 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Activity: Program and tool path parameters


In the Build a postprocessor with Post Builder section, do the following
activity:
• Program and tool path parameters 2

Post Building Techniques – Student Guide 2-27


Build a postprocessor with Post Builder

NC Data Definitions
Use the NC Data Definitions tab to define output formats for NC data.

Words

Words are the basic unit of data. Words are typically, but not always, a letter
followed by one or more digits, for example, G01, X100.35, and M03 are typical
words. We refer to the initial letter as the word address.
You can select a word from a list by its group name and name. For example
G_motion®G01–Linear Move, X®X–X Coordinate, or M_Spindle®M03–CLW
Spindle Direction appear in lists. You can choose words from a tree diagram
by their name. For example, G_motion, X, and M_Spindle appear in the
word tree diagram.
Word names in Post Builder sometimes refer to several possible releated
controller words, for example, the following post words can identify several
ontroller words:

G_Cutcom – Cutcom(LEFT/RIGHT/OFF) can output G41, G42, or G43, as


required by the event generated in the tool path.

M_Spindle – Spindle Direction(CLW/CCLW) can output M03 or M04, as


required.

Blocks

Blocks consist of one or more words arranged in the context of a machine


operation. The order of words in a block is set on the Word Sequencing tab.
You can drop a word into a block anywhere, and it assumes the correct
position.
Blocks also have names that you can select from lists or tree diagrams.
For example:

The default cutcom_off block contains the single word G_cutcom – Cutcom
Off and outputs G40 by default.

The default absolute_mode block contains the words G_cutcom – Cutcom


Off, G_plane – XY Plane Code, G_mode – Absolute Mode, and G –
Output Unit (Inch/Metric), and the default output for a metric post is G40
G17 G90 G71.

2-28 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Formats
Formats are also named and you can select a word format from a list or
a tree diagram.
There are many default named formats such as Coordinate, Digit_2, and 2
Tcode.

Post Building Techniques – Student Guide 2-29


Build a postprocessor with Post Builder

Block tab
Use the Block tab to create and edit blocks. When you create a new block on
this page, you are copying an existing block and editing it. You are limited
to copying a single existing block. If you need more than one block for your
2 function, you must create multiple blocks on the Program tab of the Program
& Tool Path tab.

Creating a New Block


You can create a new block in the following ways:
• Drag a new block into a sequence on the Program tab of the Program
& Tool Path tab.

• Copy an existing block on the Block tab of the N/C Data Definitions tab.

2-30 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Editing new or existing blocks


You can edit a block in the following ways:
Add a new word
Select applicable words from the list, and drag Add Word to the block. 2
Remove a word

Drag unwanted words to the icon, or right-click and choose Delete.


Modify a word
Right-click a word and choose from the following actions:
Edit
Opens the dialog box to edit a word.
Change Element
Lets you swap the word for another word in the same group. For
example, you can replace G17 with G18.
Optional
When a check-mark appears, the word is not output if a variable for
the word is not defined, and there will not be an error message.
Click the menu option to toggle it between selected and not selected.
G90is required — there are no G90 with the optional condition
conditions turned on turned on

No Word Separator
When selected. omits the separator, for example a space character,
before the word.
Click the menu option to toggle it between selected and not selected.
P with the optional condition P with the optional and no word
turned on separator conditions turned on

Post Building Techniques – Student Guide 2-31


Build a postprocessor with Post Builder

Force Output
Available in blocks where output is not forced by the presence of the
word.

2 The word is output, regardless of modality, provided the optional


setting does not inhibit the output.
G41with no conditions G41 with force output G41 with all conditions
turned on turned on turned on

Delete
Removes the word from the block.

Preview a word format


Examine the green box above the word parameter window to preview the
format of the selected word.
Restore a previous state
Choose one of the following:
Default
Restores the block being edited to the state last saved with the post.
Restore
Restores the block being edited to the state it was in when you began
the current edits.
If you stop editing a block, edit something else, and come back to it
later, Restore does not remove earlier edits in the session.

When you right-click a word in a block, the menu contains a mixture of


commands and status indicators, as described in the preceding paragraphs.
The status of the three indicators is shown graphically by the word in the
block, as described, and also by the presence of a check mark. In the following
graphic, the Optional status indicator is checked, meaning that the optional
output condition is turned on.

2-32 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

New Address

Select New Address from the list and drag Add Word to a block. The WORD:
user_add dialog box appears, where you can name the word, set the format,
and identify the expression for which your word reflects the value.

Text
Select the Text option from the list and drag Add Word to a block. The Text
Entry dialog box appears

Existing Words
Select the word that you want from the list.
When you choose an existing word the current value for the associated
variable is output. For example, if you choose X-Coordinate, the word is
output with the current X position in the format defined for the word.
You can specify a specific variable that you create using the User Defined
Expression option that is available in every word group.

Post Building Techniques – Student Guide 2-33


Build a postprocessor with Post Builder

Word tab
Use the Word tab to create and edit words.
A word is composed of an address leader, a number, or text and a trailer.
2 You have the same options for editing a word as you do within the event
or sequence dialogs.
To create a new word or word group, you must copy an existing word or word
group and edit the copy.

Format
You can specify the format for a selected word in the following ways.
• Select from the list of currently defined named formats

• Create a new format.

• Edit an existing format and verify that the change does not
compromise an existing word.

The green rectangle above the parameter input area shows a preview of
the output word formatting.

2-34 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Leader and Trailer


An address leader may be any characters. For NC code the address leader
is usually a single letter such as G, M, or X.
Leaders and trailers can be multiple characters such as A1=, B1=, C1=, and 2
so on for Sinumerik 840D controllers.
An example of leaders and trailers for some Siemens controls is the format
for absolute output of circle centers with I, J, and K.
G3 X-3.257 Y-47.45 I=AC(2.487) J=AC(-51.45)

Leader Trailer
I=AC( )
J=AC( )
K=AC( )

The same is true for some tool numbers, expressed as TC(1):


Leader Trailer
TC( )

Modal?
Select Yes for words that are modal. The word is output only if the value
of the expression changes. This is the default setting for all words.
Typically, modal words are for coordinate data, motion G codes, and so on.
Select No for words that must be output in every block in which the word
appears.
For example, the opstop event should always force an M01; the Modal?
option is set to No by default.

Post Building Techniques – Student Guide 2-35


Build a postprocessor with Post Builder

Maximum and Minimum


Define the maximum and minimum value that can be output with the
selected word.

2 You can define the action when maximum or minimum value is exceeded
from the following:
Truncate
The maximum or minimum value is used instead of the value specified
in NX.
Warning
Warnings are output if one of the following is true:
• The Output Warnings postprocessing option in NX is set to Yes.

• The Post Builder option Output Warning Messages on the Output


Settings®Other Options tab is selected and the Output Warnings
option in NX is set to anything other than No.

Warnings are output to a file with the base name of the output file,
and the suffix and extension warning.out.
For example, if the output file is my_part.ptp, the warning file is
my_part_warning.out.
There is no interactive warning in the NX session.
Abort
Postprocessing is aborted. An error message is output to the system
log file, Help®Log File.
The message may appear at the beginning of a lengthy trace, but you
can identify the beginning lines similar to the following:
*** IKS has been initialized ***
*** EXCEPTION: Error code 1745005 in line 560 of
o:\ugnx80\ip19\src\cams\no\ind\mom_post.c at
Tue Apr 19 11:45:16 2011 Eastern Daylight Time
+++ ADDRESS:F, Maximum is 600.000000,
this value is 619.685039

2-36 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Format tab

Use the Format tab to create and edit formats. Post Builder comes with a
default set of formats that are applied to words in the default posts. You can
also change formats within the context of the words and blocks on several
other tabs where words are displayed.
Tree diagram
The tree diagram at the left of the Format tab shows the formats that
are defined in the current post. You can edit a format by selecting it in
the tree.
You can create a new format by selecting an existing format and clicking
Create. This gives you a new format exactly like the original, with _1
appended to the name.
You can rename, cut, and paste formats, with the exception that you
cannot cut a format that is in use.

Post Building Techniques – Student Guide 2-37


Build a postprocessor with Post Builder

Preview
The green area at the top of the format window shows a preview of the
selected format.

2
Data Type
Specifies the data type as numeric or text.
You should select numeric for all NC data except for certain G codes. For
instance, if your controller needs L instead of G01, R instead of G00, CW
instead of G02, and so on, then you can change the data type to text and
change all of the codes to the text that the controller recognizes. This is
the only case we have found where it is necessary to use a text format.
If you specify text, you no other formatting options available to you.
You should try text format only if you are familiar with this area.

Number spin boxes


Let you set the number of digits to the left and right of the decimal point.

Output Decimal Point (.)


Some words do not require a decimal point, even when the value has one
or more decimal places. For example, if you want to output P3000 for a
dwell time of 3.000 seconds, you would make the format 1.3, select the
Output Trailing Zeros check box, and clear the Output Decimal Point (.)
check box.

2-38 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Check boxes
The check boxes on the Format tab do what their names indicate. Some
examples follow. The number to be output is 53.1, and the spin boxes are
set to the 5.3 format.
Check boxes selected Output
2
Output Decimal Point (.) 53.1
Output Decimal Point (.)
+53.1
Output Leading Plus Sign (+)
Output Decimal Point (.)
00053.1
Output Leading Zeros
Output Decimal Point (.)
Output Leading Zeros 00053.100
Output Trailing Zeros
Output Leading Plus Sign (+)
Output Leading Zeros +00053100
Output Trailing Zeros

If none of the decimal point, leading zeros, or trailing zeros check boxes
is selected, you will get an error message. At least one of these must be
selected to assure that the output has a clear meaning.

When the output represents a decimal value between 1.000 and –1.000, then
the following formats are useful:
Zero_int Outputs integer numbers with leading zeros.
Zero_real Outputs decimal numbers with both leading and trailing
zeros.

Post Building Techniques – Student Guide 2-39


Build a postprocessor with Post Builder

Activity: NC Data Definitions tab


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • NC Data Definitions tab

2-40 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Create new M or G code groups


M and G codes are classified into logical groups.
One such group is the Motion group. This group consists of the following
words: 2
• G00 – Rapid Move

• G01 – Linear Move

• G02 – Circular Interpolation (CLW/CCLW)

• G02 – Circular Interpolation CLW

• G03 – Circular Interpolation CCLW)

• G81 – Drill

• … several other drilling and boring cycles.

• G80 – Cycle Off

• G-Cycle Code Representative

• G – User Defined Expression

Only one word from a group can be active at any given time, because the
groups represent mutually exclusive moves. For example, a machine cannot
be moving in the G00 mode (rapid) while making a G01 move (linear feed)
simultaneously.
As a general rule, Post Builder supports all common M and G code groups. In
some instances however, certain machine tool and controller combinations
support functions that are unique and require custom M or G codes. Post
Builder allows you to create these new M or G code groups as shown in the
following activity.

Post Building Techniques – Student Guide 2-41


Build a postprocessor with Post Builder

Activity: Create a new group of coolant codes


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • Create a new group of coolant codes

2-42 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Output Settings tab


Use the Output Settings tab to control elements such as following:
• The presence of a listing file and details included in the listing.
2
• The way your post handles program groups in NX.

• The defaults for warning output and the debugging tool.

• Additional Tcl files to read before posting.

• Links to Alternate Units subposts.

You can also compare what is as stored on disk to information currently in


memory for the post you are editing, for the following categories:
• Events

• Formats

• Words

• Blocks

Post Building Techniques – Student Guide 2-43


Build a postprocessor with Post Builder

Listing File tab


Generate Listing File
When selected, your post always outputs a listing file.
2 The listing file contains a header that contains all the runtime information
that includes time and date, part name, name of the postprocessor files
used and user name.
The listing file also contains the NC file, warnings, and the absolute axis
positions.
Listing File Extension
Sets the extension used for the listing file. The name of your listing file
is the name of the output NC file, with the listing file extension. For
example, for 1234.ptp, the default listing file is 1234.lpt.
Components
Use the check boxes to control the following outputs to a table in the
listing file:
• X-Coordinate

• Y-Coordinate

• Z-Coordinate

• 4th Axis Angle

• 5th Axis Angle

• Feed

• Speed

2-44 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Other Options tab


Output Control Elements group
NC File Output Extension
Sets the default extension for the NC output file that the post 2
generates. You can override this in NX, by entering an extension in
the File Extension box in the Output File group of the Postprocess
dialog box.
Generate Group Output
Lets you define how your post handles program groups in NX. You can
define more than one NC program in a part file. If the top level group
is NC_PROGRAM and all the subgroups are in the level immediately
under NC_PROGRAM, all subgroups are output in the same NC tape
file, regardless of the setting in the post. The option controls whether
additional files are output.
By default, the Generate Group Output check box is not selected. All
group organization in NX is ignored, and a single file is output for
the selected program or program group, or for selected operations
in the same group.
Select this check box when you want additional output of a separate
NC tape file for each group immediately below the top level selected,
for example, all top level groups below NC_PROGRAM. Each file
has the same name as the top-level output file, with the group name
appended to it.
For example, if the name of the NX file is gearbox.prt and the
NC_OPERATION program has the following subgroups: ROUGHING,
FINISH_MILLING and DRILLING, the output files for the
NC_OPERATION group when the Generate Group Output check box
is selected are:
• gearbox.ptp

• gearbox_roughing.ptp

• gearbox_finish_milling.ptp

• gearbox_drilling.ptp

The behavior when the check box is selected is similar if groups have
subgroups below them.
Do not mix operations in groups with operations outside of
groups when the Generate Group Output check box is selected.
This causes unpredictable output.

Post Building Techniques – Student Guide 2-45


Build a postprocessor with Post Builder

You can use the name of the selected group or program in NX as the
program name in the Start of Program event. Access the name using
the variable mom_group_name.
Output Warning Messages
2 Outputs warnings to a warning log file when Output Warnings in the
NX Postprocess dialog box is set to its default value, Post Defined.
The system suffix and extension _warning.out are appended to the
base name of the NC output file, and the warnings file is in the same
directory as the NC output.
Display Verbose Error Messages
Displays detailed error messages if a Tcl error is encountered. If you
select the Display Verbose Error Messages check box when you are
debugging your post; you need not examine the NX log file for error
messages.
Because this option causes degradation in performance, use this
option only when you are debugging your post.

2-46 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Activate Review Tool


Opens the debugging dialog box after postprocessing is complete.
The debugging dialog box has three lists. The first list displays all
events that were created by the event generator. The second list 2
displays all of the variables that were created and passed to your
postprocessor during a selected event, including MOM variables, and
the variable values. The third list displays a list of the NC output
that your postprocessor generated.

For example, if you select an event in the first list , the data
generated by the selected event is shown in the second list , and the
NC code generated for the selected event is highlighted in the third
list .
The listing at the top of the display shows you the selected event, or
the event that caused selected NC code .

The review tool causes a significant degradation in performance.


Use this option only with relatively small files and when you
are debugging a problem.

Post Building Techniques – Student Guide 2-47


Build a postprocessor with Post Builder

User Tcl Source


Identifies an additional Tcl file to read based on the options in this section.
This file must be in the default postprocessor folder.

2 Source User’s Tcl File


Includes handlers for UDE post commands that you create in your
own Tcl file. Your Tcl file must be in the same folder as the current
postprocessor.
File Name
Specifies the name of the file that you want sourced into your post.

2-48 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Optional Alternate Units Subpost


The options under Optional Alternate Units Subpost work together with
the option Units Only Subpost in the Create New Post Processor dialog
box.
Default
2
Modifies the postprocessor file name to the format for a units-only
subpost. The name links your post to a subpost with millimeter units
for an inch-unit post and subpost with inch units for a millimeter-unit
post. You can explicitly create the subpost later, after your post is fully
defined. You can also link to an existing subpost, if, for example you
are linking a family of posts for a complex machine to a single subpost.
For example, if the post you are creating is named new_post and
has inch units, the default name for the alternate units post is
new_post__MM.pui. If the post you are creating is named my_post and
has millimeter units, the default name for the alternate units subpost
is my_post__IN.pui. In the name of the alternate units post, the unit
abbreviation is in uppercase and it is preceded by two underscores.
If the alternate units subpost exists and is in the same folder as your
post, it is used automatically when you request output in the units
of the subpost.
Specify
Lets you specify an existing units-only subpost to link to your main
post. The subpost must have the correct units, and must be compatible
for the machine tool for which you are defining your post. For example,
if your main post has millimeter units, the subpost you select must
be for inch output.
Typically, you use this option to reuse the same units-only subpost for
a set of linked posts, such as the set of posts for a complex machining
center.
Select Name
Available when Specify is selected.
Lets you navigate to and select an existing subpost. The subpost must
have the correct units.

Link Tcl Variables to C Variables


Enables NX Post to process the MOM Tcl variables more efficiently. This
option can improve the performance of NX Post by approximately 25
percent; however, it might cause NX Post to fail in some situations.
Use this option with caution, and, as always, thoroughly test your
postprocessor before distributing it.

Post Building Techniques – Student Guide 2-49


Build a postprocessor with Post Builder

Activity: Output settings


In the Build a postprocessor with Post Builder section, do the following
activity:
2 • Output settings

2-50 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Post Files Preview tab


Use the Post Files Preview tab to examine the current and previously saved
source code for the definition file and event handlers.
When you select the Event Handlers tab or the User Defined Events tab, you 2
can browse Tcl code.

When you select the Definitions tab you can browse the elements of the
definition file.

Post Building Techniques – Student Guide 2-51


Build a postprocessor with Post Builder

Post Files Preview property page

The Post Files Preview property page allows you to examine the Definition
file (.def) and the Event Handlers (.tcl) before output generation. Newly
defined code appears in the top window while the original code is displayed
in the bottom window.

2-52 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Build a postprocessor with Post Builder

Summary: Build a postprocessor with Post Builder


The Post Builder is an efficient and robust tool that can be used to build the
majority of the Postprocessors that are required in today’s manufacturing
environment. The following functions were used in conjunction of building a
Postprocessor with the Post Builder:
2
• Created a directory structure for testing Postprocessors developed with
the Post Builder.

• Creation, modification and customization of Event handlers with the


Program and Tool path function.

• Defined output formats

• Modified listing and output options.

• Verified the output of your Postprocessor using the Post Review Tool.

Post Building Techniques – Student Guide 2-53


2
Lesson

3 Units-only subposts

Purpose 3
This lesson describes the process for creating a subpost with units that are not
the default units of the main post. This subpost is called automatically by the
main post when you define the output in units other than the default units.

Objective
When you complete this lesson, you will be able to:
• Create an alternate units subpost.

• Link a subpost to a main post.

Post Building Techniques – Student Guide 3-1


Units-only subposts

Defining and editing units-only subposts


The dialog box to define and edit a post processor shows the name of the
currently open post processor in its title bar.
Values from the main post are shown in blue boxes that cannot be changed in
this dialog box.
Values for the units of the subpost appear in white boxes that you can modify.
The following main tabs are available:
3 Units Parameters Values default to standard conversions of values in the
main post.
If your machine and controller manuals specify different
values from the automatically converted values, you can
set them on this tab.
WORD Values for word formats are defaulted to the same number
of digits, with a shift in the decimal point.
For example, if the format is 4.4 in Inches, it is
represented in this dialog box as 9999.9999.
The metric format is automatically converted to 9999.999.
If your controller recognizes a different format for
alternate units, you can set it on this tab.
FORMAT Values for word formats are defaulted to the same number
of digits, with a shift in the decimal point.
This tab has formats for absolute coordinates, coordinates,
and feed rates.

3-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Units-only subposts

Where do I find it?

Application Post Builder


You must have a main post from
NX 8 or later on which to base the
Prerequisite subpost.
Toolbar NX/Post Builder®Open
NX/Post Builder®File®Open
NX/Post Builder®File®Recently
Menu Opened Posts
Create New Post
Processor dialog
box OK

Post Building Techniques – Student Guide 3-3


Units-only subposts

Activity: Create a units-only subpost


In the Units-only subposts section, do the following activity:
• Create a units-only subpost

3-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Units-only subposts

Summary: Units-only subposts


In this lesson, you:
• Created a new alternate units subpost.

• Linked a subpost to the main post of a family of posts that work together
to program a complex machine.

Post Building Techniques – Student Guide 3-5


3
Lesson

4 Post Builder for Wire EDM


applications

Purpose
Wire EDM machines have requirements that differ from mills and lathes.
This lesson describes the Post Builder options that are unique to creating a
post for a wire EDM.
4
Objective
After you complete this lesson, you will be able to:
• Use the Post Builder to build 2-axis or 4-axis Wire EDM postprocessors.

Post Building Techniques – Student Guide 4-1


Post Builder for Wire EDM applications

Creating 2-axis and 4-axis wire EDM postprocessors


Two options are available in Post Builder for creating wire EDM
postprocessors. They are:
• 2-axis

• 4-axis

After you make the selection of a 2-axis or 4-axis Wire EDM postprocessor,
you must specify the type of controller that you want. Your choices are:
Generic, Library, and User’s.
Generic
Uses generic options common to most machine tool controllers.
Library
Lets you select Agie, Charmilles and Mitsubishi controllers. These
templates contain the basic codes required for the most common wire
EDM codes such as threading, start and end of cut, and power settings.
User’s
Lets you select a post that you created previously as a template. Click
Browse to select the existing postprocessor.

4-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for Wire EDM applications

Wire EDM specific parameters


Wire Tilt Control
Defines the method to control the upper wire guide.
Angles
Outputs tilt and lead relative to the direction of motion. This is typical
output for Agie controllers.
Coordinates
Outputs upper wire guide coordinates relative to the X and Y position
of the lower wire guide. This is typical of the output for Mitsubishi
and Charmilles controllers.

Post Building Techniques – Student Guide 4-3


Post Builder for Wire EDM applications

Activity: Create a 2-axis Wire EDM post


In the Post Builder for Wire EDM applications section, do the following
activity:
• Create a 2–axis Wire EDM post

4-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for Wire EDM applications

Summary: Post Builder for Wire EDM applications


The flexibility of Post Builder allows you to easily generate postprocessors for
2 axis and 4 axis wire EDM machines. In this lesson you were introduced to:
• Creating a 2-axis Wire EDM Postprocessor using Post Builder.

Post Building Techniques – Student Guide 4-5


4
Lesson

5 Post Builder for 4-axis and


5-axis mills

Purpose
Mills with 4 and 5 axes have rotary heads, rotary tables, or a combination
of the two, that you must configure. This lesson describes the Post Builder
options that are needed to define 4th and 5th rotary axes.

Objective
After you complete of this lesson, you will be able to:
5
• Use Post Builder to build 4-axis and 5-axis mill postprocessors.

Post Building Techniques – Student Guide 5-1


Post Builder for 4-axis and 5-axis mills

Creating 4-axis and 5-axis mill postprocessors


In the Create New Postprocessor dialog box, the following options are
available for multi-axis mills:
• 4-Axis with rotary table

• 4-Axis with rotary head

• 5-Axis with dual rotary heads

• 5-Axis with dual rotary tables

• 5-Axis with rotary head and table

In the editing dialog box, on the Machine Tool tab, you can select General
Parameters, Fourth Axis and Fifth Axis parameters.

when you click Display Machine Tool, a generic machine tool of the type you
selected, which shows current axis limits, is displayed.

5-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for 4-axis and 5-axis mills

Mill Fourth Axis and Fifth Axis parameters


The fourth axis dialog box and fifth axis dialog box set the same parameters,
with a couple of exceptions that are mentioned in the following list. The
default settings work for most machines.

There is a general restriction in Post Builder that the C axis (XY plane)
cannot be the 4th axis of a 5-axis machine tool.
In order to get the correct output for a dual head rotary 5-axis machine
tool with a B-axis in the ZX plane attached to a C-axis in the XY plane,
you must define the fourth axis as B in the ZX plane, and the fifth axis
as C in the XY plane. The machine tool display function will not work
correctly for this configuration; however, the NC program output will
be correct.

Machine Zero to 4th Axis Center


Available when Fourth Axis is selected.
Sets the distance from machine zero to the center of rotation for the 4th
axis. 5
This value must be specified for the postprocessor to map correctly
between the MCS programmed in NX and the machine tool coordinate
system.

4th Axis Center to 5th Axis Center


Available when Fifth Axis is selected.
Sets the distance between the centers of rotation for the 4th axis and
the 5th axis.
This value must be specified for the postprocessor to map correctly
between the MCS programmed in NX and the machine tool coordinate
system.

Rotary Motion Resolution (Deg)


Controls the number of digits to which the calculated rotary angles are
rounded by the postprocessor.

Angular Offset (Deg)


Sets the value that needs to be added to adjust the rotary angle to 0.0
when the tool axis is (0,0,1).
For example, some Sundstrand head and table machine tools require an
offset of –90, because prior to entering the offset, a tool axis vector of
(0,0,1) results in output of an angular position of 90.0 degrees for the
fourth axis.

Post Building Techniques – Student Guide 5-3


Post Builder for 4-axis and 5-axis mills

Axis Rotation
Defines whether the axis rotates according to the right-hand rule. The
rule states that when you hold your right hand with the thumb pointing
in the positive direction of the rotation axis, the fingers curl in the positive
direction of rotation.
Normal is the default option.
Select Reverse if your table does not rotate according to the right-hand
rule.
For example, if you get B90 output when you require B–90, you may need to
select Reverse. As always, test the post thoroughly.
Axis Direction
Defines how the rotary table determines whether to rotate clockwise or
counterclockwise.
Magnitude Determines Direction
Rotation to a larger angle is always clockwise and rotation to a smaller
angle is always counter clockwise.
5 B–90and B90 cause rotation to different positions that are 180 degrees
apart on the rotary axis.
Typically, the travel limits on this type of table are more than 360
degrees, for example, –9999 to 9999.
Sign Determines Direction
The sign determines only the direction of rotation.
B90 and B–90 cause rotation to the same position on the rotary table.
When you program B90, the table rotates clockwise from its current
location to 90 degrees. When you program B–90, the table rotates
counterclockwise from its current location to 90 degrees.
Typically, the limits on this table are from 0 to 360.

Axis Limits (Deg)


Sets the minimum and maximum angles that you can program for the
axis.
The postprocessor measures the range of travel clockwise from the
minimum angle to the maximum angle.
For example, if you have a rotary axis that has 40 degrees of travel, you
can enter one of the following sets of values:
• –20 degrees for the minimum and 20 degrees for the maximum.

• 340 degrees for the minimum and 20 degrees for the maximum.

5-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for 4-axis and 5-axis mills

This Rotary Axis Can Be Incremental


Outputs axis motion incrementally when you define operation start and
end events for incremental output in NX tool paths.
In the Machine Control section of the operation editing dialog box, create
start of path events and end of path events for each operation.
For the operation start event, enter:
SET/MODE,INCR

For the operation end event, enter:


SET/MODE,ABSOL

Post Building Techniques – Student Guide 5-5


Post Builder for 4-axis and 5-axis mills

Rotary Axis Configuration dialog box


Under Rotary Axis, click Configure to open the Rotary Axis Configuration
dialog box.

4th Axis and 5th Axis


Display the name for the type of axis that you selected in the Create New
Postprocessor dialog box: Head or Table.
For each axis, you can set:
• The plane of rotation, for example, XY, YZ, or ZX.

• The word leader, for example, A, B, or C.

Max. Feed Rate (DegMin)


Sets the maximum rotary feed rate for the machine tool.
If the amount of rotation during a combined linear and rotary move
exceeds the maximum degrees per minute, the post processor reduces the
feed rate so that it does not exceed this value.

5-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for 4-axis and 5-axis mills

Pivot Distance
Sets the distance from the head or table rotation pivot point to the spindle
gage point.
This option is not valid for the dual rotary type five-axis machine tool.
You can specify this value in either the fourth axis or the fifth axis dialog
box; however, there is only one pivot distance on the machine tool.
Axis Limit Violation Handling
Warning
Outputs a warning to the listing file or warning file, if one or both
options are active. No corrective action is taken.
Enable warning output on the Output Settings®Other Options tab.
Enable listing output on the Output Settings®Listing File tab.
Retract/Re-Engage
• Retracts to clearance cylinder or sphere.

• Repositions the rotary axis to a valid position, if possible. 5


• Re-engages to a user-defined distance above the part.

• Feeds to the previous position.

• Moves to the programmed end point.

To change the default retract or re-engage distance you must modify


the custom command PB_CMD_init_rotary. Modify the following lines:
set mom_kin_retract_plane 10.0
set mom_kin_retract_distance 10.0
set mom_kin_retract_type "PLANE" ;# DISTANCE or PLANE
set mom_kin_reengage_distance .20

User Defined
Lets you click Handler to specify a block with appropriate words or
custom commands to execute when a rotary axis limit violation occurs.

Post Building Techniques – Student Guide 5-7


Post Builder for 4-axis and 5-axis mills

Linearization Interpolation
Lets you specify the default linearization tolerance. The tool path is
broken into moves that are within the specified tolerance. By default,
linearization is set to off.
Combined rotary and linear motion causes the motion to deviate from the
desired straight line move. To activate linearization for four-axis and
five-axis milling machines, you can use the post command LINTOL in NX.

Under Machine Control, create a start of path event, User Defined. The
syntax for this command is as follows:
5 LINTOL/ [ON | OFF | n]

When you specify a tolerance value n, it implicitly turns on linearization.


ON turns on linearization with the last specified linearization value.
OFF turns off linearization.
You can also use linearization for mill turn machines to linearize the XZC
moves. To use linearization for XZC posts, set the output mode to polar.
To do this, use the default setting for the post command: SET/POLAR,ON.
The syntax for the command is:
SET/POLAR, [ON | OFF]
ON sets the output mode to polar. The coordinate output is XZC and is
linearized if needed.
OFFsets the output mode to Cartesian. The coordinate output is XYZ
and no linearization takes place.
For head-head machines, linearization is not in effect when the NC
points are output at the tool tip. For example, when the Z Offset
value for the tool, or the gauge-pivot distance in the post, is 0.0.

5-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for 4-axis and 5-axis mills

Activity: Create a 5-axis Mill post


In the Post Builder for 5-axis mill applications section, do the following
activity:
• Create a 5-axis Mill post

Post Building Techniques – Student Guide 5-9


Post Builder for 4-axis and 5-axis mills

Summary: Post Builder for 5-axis mills


In this lesson you were introduced to:
• Creating a 5-axis mill postprocessor using the Post Builder tool.

5-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Lesson

6 Post Builder for lathe


applications

Purpose
Lathes have requirements that differ from mills and wire EDM machine tools.
This lesson describes the Post Builder options that are unique to building
postprocessors for 2-axis lathes.

Objective
After you complete this lesson, you will be able to:
• Use Post Builder to build 2-axis lathe postprocessors.

Post Building Techniques – Student Guide 6-1


Post Builder for lathe applications

Creating lathe postprocessors


In the Create New Postprocessor dialog box, lathe options are the same
as mill options.

Currently, you can create only one type of lathe postprocessor using Post
Builder:
• 2-Axis

In the editing dialog box, on the Machine Tool tab, when you select General
Parameters, you see options that are shared by all types of machines, and
options that are unique to lathes.

6-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for lathe applications

2-axis lathe-specific parameters


Output Method
Defines the tool tracking method.
Tool Tip
Makes the X-values and Z-values in your NC output file represent the
tool tip location. Resets the tool tip location with every tool change.
The basic elements for tool tip programming are:
• A FROM command at the beginning of the program to define the
initial turret reference position.

• A G92 block with each tool change to take into account the change
in offsets.

• A GOHOME or return to the home position to return to the turret


reference position.

Turret Reference
Makes the X-values and Z-values in your NC output file represent the
turret reference location, similar to the method for milling machine
programs.

Turret 6
Defines whether you have one or two turrets.
One Turret
The default option.
Two Turrets
Currently, when you select this option, the turrets must be a fixed
distant apart and may not move independently.
becomes available when you select Two Turrets.
Configure
Available when you select Two Turrets.
You must select the names of the two turrets from lists of recognized
names, and you must specify the X-distance and Z-distance between
them. The postprocessor adds the offset values to the X-axis and
Z-axis coordinates when the secondary turret is used. The distance
must be measured from the primary turret to the secondary turret.

Post Building Techniques – Student Guide 6-3


Post Builder for lathe applications

Axis Multipliers
Specifies that the machine requires diameter programming. You can also
use it if your shop practice is to use diameter programming.
Diameter Programming
Outputs the X-word as a diameter. When you select 2X, then 2I
becomes available. Select 2I if your machine also requires the I-value
to be multiplied by two.
Mirror Output
Lets you program your part in other quadrants and output in the
first, or positive, quadrant.
Select the combination of X, I, Z, and K multipliers that you require.
For each word selected, the corresponding value is multiplied by
negative one in the output.

6-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Post Builder for lathe applications

Activity: Create a lathe post


In the Post Builder for lathe applications section, do the following activity:
• Create a lathe post

Post Building Techniques – Student Guide 6-5


Post Builder for lathe applications

Summary: Post Builder for lathe applications


The flexibility of Post Builder allows you to easily generate postprocessors for
2-axis lathes. In this lesson you were introduced to:
• Creating a 2-axis lathe postprocessor using Post Builder.

6-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Lesson

7 Create Mill-Turn postprocessors

Purpose
This lesson describes the procedures required to build mill-turn
postprocessors through the use of Post Builder.

Objective
When you complete this lesson, you will be able to:
• Construct a postprocessor for a mill-turn machine.

Post Building Techniques – Student Guide 7-1


Create Mill-Turn postprocessors

Create a mill-turn post


1. Create a new 2-axis lathe post.

2. Save the 2-axis lathe post using one of the following options:
• Save it as lathe_tool_tip in the folder where you intend to create your
mill-turn post.

• Save it in your postprocessor folder, using a name of your choice.

3. Create a new mill post and select 3-Axis Mill-Turn (XZC).

4. In the mill post, on the Machine Tool tab, on the General Parameters
page, under Machine Mode, do one of the following:
• If you saved the 2-axis lathe post as lathe_tool_tip in the folder where
you intend to save your mill-turn post, select XZC Mill to automatically
use the lathe_tool_tip post.

• If you saved your lathe post in your postprocessor folder using a


name of your choice, select Simple Mill-Turn and click Select Name to
navigate to your lathe post.

5. Complete your mill post and save it to the folder where you saved your
lathe post.

6. In NX, on the Navigator toolbar, click Geometry

7. Make sure that all the lathe tool paths are in the MCS_SPINDLE group
object.
7
8. Make sure that all the mill tool paths are in the MCS_MILL group object.

9. Postprocess your tool paths.

7-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Create Mill-Turn postprocessors

Activity: Create a Mill-Turn postprocessor


In the Create Mill-Turn postprocessors section, do the following activity:
• Create a Mill-Turn postprocessor

Post Building Techniques – Student Guide 7-3


Create Mill-Turn postprocessors

Define heads for mill-turn centers


Some mill-turn centers use special heads for turning, for example, Z-axis,
X-axis, Y-axis or 5-axis work. You can output commands to use these heads
by the following procedure:
1. Create the postprocessors for the auxiliary heads that you need, and save
them to one common folder.
For example, if you require an X-axis head and a turning head in addition
to the main mill-turn XZC head, create an X-axis mill post and a lathe
post, and configure them to your machine and controller combination.

2. Create a milling post in the common folder, and in the Create New Post
Processor dialog box, under Machine Tool, select 3-Axis Mill-Turn (XZC).
This is your main post. Select it from the list of postprocessors in NX
when you are posting programs for your mill-turn center.

3. In the mill-turn post, on the Program & Tool Path tab, on the Linked
Posts tab, select the Link Other Posts to This Post check box.
In the Linked Posts dialog box, the Post contains this_post. You must
supply a name to reference the current post in the NX HEAD event.

4. In the Linked Posts dialog box, in the Head box, enter a name for the
head used in the main post.
Use a name that is meaningful to both you and your users. For example, if
the main post moves primarily in the Z-axis, call it ZHEAD.
Always use uppercase letters for head names in your post and
in NX. Tcl is case sensitive, so a standard practice of using only
7 uppercase letters avoids issues with inconsistent naming.

5. (Optional) If your machine and controller combination requires special


commands at the start or end of head use, click Start of Head and End of
Head to add the necessary commands.

6. In the Linked Post dialog box, click OK.

7. Repeat the following for each linked post:


a. On the Linked Posts tab, click New.

b. In the Linked Post dialog box, click Select Name.

c. In the Select a file dialog box, from the common folder, select one of
your posts for other heads on the machine and click OK.

7-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Create Mill-Turn postprocessors

d. In the Linked Post dialog box, in the Head box, enter a meaningful
name for the head that corresponds to the post that you specified.
For example, you could call it XHEAD or TURN.

e. (Optional) If your machine and controller combination requires special


commands at the start or end of head use, click Start of Head and End
of Head to add the necessary commands.

f. In the Linked Post dialog box, click OK.

8. Save the completed main post in the common folder.

9. In NX, open a part with a suitable test program that uses all of the heads
on your machine tool.

10. In the Method view of the Operation Navigator, create methods that
correspond with the available head posts.
For example, you can create methods for turning, X-head milling, X-head
drilling, Z-head milling, and so on.

11. Drag operations from the Unused Items folder to your methods.

12. For each method, do the following:


a. Right-click the method and choose Object®Start Events.

b. In the User Defined Events dialog box, from the Events Available list,

select Head and click Add new event .

c. In the Head dialog box, verify that Status is set to Active.


7
d. Select the Name Status check box.

e. In the Name box, enter the name of the head exactly as you specified it
in the main post under Linked Posts.

f. Click OK.

g. In the User Defined Events dialog box, click OK.

13. Postprocess your test program and verify whether all output is correct.

Post Building Techniques – Student Guide 7-5


Create Mill-Turn postprocessors

Activity: Create a 5-axis multi-link mill-turn post


In the Create Mill-Turn postprocessors section, do the following activity:
• Create a 5-axis multi-link mill-turn post

7-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Create Mill-Turn postprocessors

Summary: Create Mill-Turn postprocessors


When you use Post Builder to generate linked postprocessors for
combination-type machine tools, you can:
• Save time.

• Customize each section of the post.

• Reuse sections of a post on machines with common requirements.

Post Building Techniques – Student Guide 7-7


7
Lesson

8 Tcl basics for Post Builder

Tcl Basics for Post Builder

Purpose
This lesson describes the basics of the Tcl scripting language that is used by
existing NX Post and Post Builder programs, within postprocessors that you
create, and for customizing that you perform.

Objectives
After you complete this lesson, you will be able to:
• Interpret the syntax and basic structures of Tcl.

• Write simple Tcl programs.

Post Building Techniques – Student Guide 8-1


Tcl basics for Post Builder

Tcl
Tcl is public domain software. The Tcl source and a link to a provider of the
compiled executable is available at tcl.sourceforge.net. Tcl stands for tool
command language. Tcl is an interpreted language, that is, a Tcl script is
interpreted at run time by a Tcl interpreter. The difference between Tcl and a
compiled language such as C or GRIP is that you can make changes to the
scripts and test them without having compile your code.
In NX CAM, you use Tcl for procedures in NX Post, Process Assistants, Shop
Documentation, the internal CLSF, and Post Builder. You also use Tcl to
create the following:
• User-defined event handlers

• User-supplied rules

Tcl has an extension called Tk, which stands for tool kit. Tk provides user
graphic interface elements such as buttons, check boxes, and scroll bars.
You can open a Tk window by running the program ugwish.exe in the
\mach\auxiliary directory.
Although Post Builder 8.0.0.4 uses Tcl 8.4.19 internally, NX Post uses
an older version. Siemens PLM Software recommends that you follow
the 8.0.5 syntax to maintain compatibility with NX Post.

You can find Tcl 8.0.5 command documentation at:


http://www.tcl.tk/man/tcl8.0/

In Tcl syntax, the following grouping symbols are necessary:


() Parentheses
[] Brackets, or square brackets
{} Braces, or curly braces

8-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl command structure


Tcl is a command-based language. Commands instruct the Tcl interpreter to
perform some type of task.
Commands are made up of words that include the name of the command
and may also include options and arguments. The basic syntax of a Tcl
command is:
command argument1 argument2 argument3 ...

Command arguments

Arguments can be any type of information that a command can process,


change, or use.
In the command set principal_axis X, the command is set, which instructs to
interpreter to assign a value to a variable. The two arguments convey the
following information:
8
The first argument, principal_axis, is the name of a variable to be assigned a
value. The variable is created if it does not already exist.

The second argument, X, is the text string to assign to the variable.

Post Building Techniques – Student Guide 8-3


Tcl basics for Post Builder

Command options
Options are used with some commands to give the interpreter detailed
instructions of the task that the command must perform. Options begin with
the ‘–’ character.
For example, glob -nocomplain *.ini consists of:
The command glob, which instructs the interpreter to match patterns using
the standard file name wild card format.

The option -noclomplain which instructs the interpreter to return an empty


list if nothing matches. Without this option, an error would occur if there
are no matches.

The argument *.ini, which matches any text string that ends with .ini.
The effect of the command, when used in the correct context, is to identify
all file names that have the extension .ini.

Words
Tcl command strings are divided into words. By default, white space
characters divide strings of text characters into words.
In your programs, you often group words and white space with brackets or
braces to create words that consist of two or more other words. Brackets and
braces have different meanings to the interpreter. Braces prevent variable
substation from taking place on their content.

8-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Specifying the order in which words are interpreted


Tcl is structured so that you can specify which words to interpret first. This
allows you to combine commands to achieve a more complex result. For
example:
set ini_file_list [glob -nocomplain *.ini]

The set command is going to assign a value to the variable ini_file_list.


The third word in the command consists of other words grouped inside square
brackets.
You can think of the content of the square brackets as an inner command.
The square brackets tell the interpreter to analyze their content before
doing anything else with the line, and substitute the resulting value before
interpreting the outer command, set.
The inner command glob -nocomplain *.ini is interprested first, and the
result is inserted into the set command string.
The result of the entire line is to assign the names of all files with the .ini
extension to the variable ini_file_list. The variable ini_file_list becomes a
Tcl list, or, a sequence of words, where words are:
• Sets of characters separated by spaces.

• Sets of words and spaces grouped in braces.

Post Building Techniques – Student Guide 8-5


Tcl basics for Post Builder

Tcl variables

Variables
A variable can be thought of as a named place holder for information. In
many languages other than Tcl, variables must have a declared type, such
as numbers or strings of text characters. In these languages, in order to set
aside the right amount of memory to hold a value of the corresponding type,
you must declare variables before you use them.
Tcl variables always hold text. You need not declare a Tcl variable before
you use it.
The only declaration statement in Tcl is used to set the scope of a variable,
or whether the variable is known throughout the entire program, or only
within the procedure that contains it.

Variable names
A Tcl variable name must start with an alphabetic character and can consist
of alphanumeric characters and the underscore. Variable names are case
sensitive. For example, the following are all different variables.:
X
x
this_is_a_Variable
pre_drill
PRE_DRILL
mom_head_name

By convention, mom variables start with mom_ in lowercase letters. Siemens


PLM recommends that you use variable names that follow the convention of
using only lowercase letters and underscores.

8-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Value of variables
When you execute the set command at the Tcl command prompt % to create
or modify a variable, the interpreter responds with the value that is stored in
the program memomry. For example:
% set X 10.5
10.5
% set mom_sys_debug_mode OFF
OFF

At the command prompt, you can use the set command with only one
argument, a variable name, to see the current value. In the following
command line example, we use set to define a variable X, and then use set to
find the current value of X:
% set x 10.5
10.5
% set x
10.5

The unset command removes a variable from your program. The command
prompt returns nothing if the command is successful, but there is an error
message if there is no such variable.
% set pi 3.1415926535897932384626433832795
3.1415926535897932384626433832795
% unset pi
% set pi
can’t read "pi": no such variable
% unset fred
can’t unset "fred": no such variable

Post Building Techniques – Student Guide 8-7


Tcl basics for Post Builder

Scope of variables
In Tcl, the scope of variables can be either local or global.
A local variable is a variable that is recognized only in the procedure in which
it is declared. When the procedure ends, its local variables are removed.
In Tcl, a procedure is the equivalent of a subroutine or function in other
programming languages.
A global variable persists through the life of the program, outside of any
procedures. You can access the value of a global variable between calls to a
procedure, or share it among multiple procedures. The following shows the
method to set the scope of a variable to global:
global cycle_name

The variable cycle_name can be set, accessed, or modified in any procedure


in the post.
You must use the global command to specify global variables in procedures
that use them. You can specify more than one global variable on the same
line. In the following example from Post Builder, two global MOM variables
are used:
proc PB_CMD_end_of_alignment_character {} {
# This command restores sequnece number back to orignal setting.
# This command may be used with the
# command "PM_CMD_start_of_alignment_character"
#
global mom_sys_leader saved_seq_num
if { [info exists saved_seq_num] } {
set mom_sys_leader(N) $saved_seq_num
}
}

The indentation combined with the placement of braces in the preceding


example conforms to a common programming standard that makes the
code easier to read.

8-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Arrays of variables
You can define variable arrays in Tcl.
Example:
• mom_pos(0) can have a value of 12.4567.

• mom_pos(1) can have a value of 33.9876.

• mom_pos(Xstr) can have a value of “X string is”.

In Tcl arrays, the values and the indices are character strings. In the last
example, mom_pos(Xstr), the character string Xstr is the index.
By convention, in Post Builder, array members use the numbers 0, 1, 2, and
so on as index strings . For example, mom_pos(0) stores an X-coordinate,
mom_pos(1) stores a Y-coordinate, and mom_pos(2) stores a Z-coordinate.

To define an array, you must place an index in parentheses after the variable
name:
% set myarray(0) 3.14
3.14
% set myarray(one) SomeValue
SomeValue

To obtain all indices and corresponding values in an array, you must use the
array get command:

% array get myarray


0 3.14 one SomeValue

The output of the array get command is a series of text strings separated by
spaces. Each array index is followed by the value of the corresponding array
element. You can interpret the example output as follows:
• The first character string, 0, is the first index.

• The value of the array member identified by index 0 is the second


character string, 3.14. 8
• The next string, one, is the second index.

• The value identified by index one is SomeValue.

To undefine an array, use the array unset command.


% array unset myarray

After you undefine an array, the array get command used on the undefined
array does not return a list, and it does not cause an error.

Post Building Techniques – Student Guide 8-9


Tcl basics for Post Builder

Working with variables


The Tcl interpreter does not directly work with numbers. To do math
with values that represent numbers, you must use commands that work
with numbers. For example, the expr command is used to evaluate math
expressions:
% set x 0.866
0.866
% set y 0.5
0.5
% set ang [expr atan2($y,$x)]
0.52361147777

The preceding example shows variables being referenced in a command. The


$ character tells the Tcl interpreter to substitute the value of a variable.

The interpreter makes exactly one substitution pass before any interpretation
takes place. After the substitution, the example command is interpreted as:
set ang [expr atan2(0.5,0.866)]

The value of the variable named x is substituted for $x, and the value of the
variable named y is substituted for $y.
The example also shows one of many built-in math functions that are
arguments to expr, atan2(y,x). Because Tcl does not work with math and
numbers directly, if you try to use arguments to the expr command without
expr, you get an error like the following:

% atan2($y,$x)
invalid command name "atan2(0.5,0.86602540378)"

The atan2 function and many other functions that work with angles accept
and return values in radian measure.
You can define variables to hold radian conversion factors. Post Builder
handles conversion between degrees and radians with the following code:
% set RAD2DEG [expr 90.0 / asin(1.0)]
57.2957795131
% set DEG2RAD [expr asin(1.0) / 90.0]
8 0.0174532925199

Thus, to obtain the value of the previous example in degrees, you could write:
set ang [expr atan2($y,$x) * $RAD2DEG]
30.0007277808

You can be more precise:


% set x 0.86602540378
0.86602540378
% set y 0.5
0.5
set ang [expr atan2($y,$x) * $RAD2DEG]
30.0000000001

8-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Additional variable substitution examples


In the following examples, lines that begin with % (percent sign) show input
at the Tcl command prompt. The following lines show the returned values.
% set a N
N
% set b X
X
% set c $a$b
NX
% set b 32
32
% set a b
b
% set a $b
32
% set c $b+$a+$b
32+32+32
% set c [expr $b+$a+$b]
96
% set a $b.3
32.3
% set a $b9
can’t read "b9": no such variable

Post Building Techniques – Student Guide 8-11


Tcl basics for Post Builder

Determining set variables


You sometimes need to know whether a variable name is safe to use in your
procedure. For example, there are many mom variables, but they may not
always be defined. At the Tcl command prompt, if x is undefined, you can
type set x for the following result:
% set x
can’t read "x": no such variable

Note that when a command expects a variable name, you do not use a dollar
sign. It would be a mistake to use $x in the preceding example.
If you attempt to use an undefined variable in an executing program, you
get a run-time error.
In Tcl you can use the info command to check many things by giving it
different arguments. To check whether a variable exists, use the command
info exists follwed by the name of a variable. You must not use a dollar
sign in front of the variable name.
% set pi 3.14
3.14
% info exists pi
1
unset pi
% info exists pi
0

Tcl follows a common convention. The command info exists returns 1, or


true, when the variable is defined, and 0, or false, when the variable is not
defined.
To use the info exists command effectively, you must use the if command.
if
The if command executes the block of code that is its second argument, if
its first argument, a logical comparison, evaluates to 1, the value for true
in logic commands.
if {[info exists variablename]==1} {
# some code that uses the variable
8 }

The first argument to if is the pair of commands in the first braces. The
result of the command in the brackets is compared to 1. If the command
evaluates to anything but 1, the comparison returns 0, a logical false, and
the second argument, a block of code in braces, is ignored. If the command
evaluates to 1, then the comparison returns 1, a logical true, the next
argument, a block of code in braces, is executed.

8-12 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl control of word structure


Tcl words break at whitespace characters: space, tabs, and newlines.
Semicolons end a command.
The following are exceptions:
• Double quotes prevent breaks and must be used to specify strings that
have spaces:
% set X "this is a word which has spaces"
this is a word which has spaces

• Curly braces prevent breaks and substitutions:


% set Y {{nested }{braces}}
{nested }{braces}
% set X 27.5
27.5
% set Y "X is $X"
X is 27.5
% set Y {X is $X}
X is $X

• The backslash is the escape character. A backslash removes the special


meaning of characters, including spaces:
% set Z word\ with\ \[\ $\ and\ spaces
word with [ $ and spaces

• You can use the backslash before the dollar sign to avoid getting an error
message when you want to output a dollar sign.
% puts "The cost is $100"
can’t read "100": no such variable
% puts "The cost is \$100"
The cost is $100

• The closing square bracket does not need to be escaped:


% set XX \[\ escaped,\ ]\ not\ escaped
[ escaped, ] not escaped

If in doubt about a character, escape it — it does no harm.


8
• Substitutions do not change word structure:
% set abc "two words"
two words
% set b $abc
two words

Post Building Techniques – Student Guide 8-13


Tcl basics for Post Builder

Tcl special characters


Some characters, such as $ (dollar sign), have special meaning. You must
escape special characters to output them as literal characters.
Example with special meaning
Character
removed
$ \$
\\ — outputs \ — useful in windows
\ — the escape character or backslash
paths
; \;
[ \[
{ \{
} \}
" \"
# \#
] \]

There are other special characters that require the escape character to give
them their special meaning. In many languages, these character strings
are called escape sequences.
Character Meaning in output
\n newline
\t tab

Examples:
% puts stdout "\tFred"
Fred
% puts stdout "Tab\tSeparated"
Tab Separated
% puts stdout "High\nLow"
High
Low
% puts stdout "\"Quoted\""
"Quoted"
% puts stdout "\$100"
8 $100

8-14 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl mathematical expressions


Tcl mathematical expressions are performed by the expr command.

Basic operators Operation


+ addition
– subtraction
/ division
* multiplication
sin(x) sine of x, where x is in radians
cos(x) cosine of x, where x is in radians
tan(x) tangent of x, where x is in radians

More complex operators, such as inverse trigonometric and logarithmic


functions are also available.

Examples

Spaces around th eoperators are neither required nor meaningful, but they
make your code easier to read
% expr 1+2
3
% expr 1 + 2
3

As with other languages, there is a hierarchy of operator precedence. For


example, multiplication and division are performed before addition and
subtraction:
% expr 1 + 2 * 5
11
% expr 2 * 3 + 1
7

As with other languages, you can group operands with parentheses to control
the order of arithmetic operations, and to make you intention clear to anyone
who reads your code:
% expr (1 + 2) * 5
8
15
% expr 2 * (3 + 1)
8

You must do radian to degree conversion before doing trigonometric functions.


For example, to obtain the sine and cosine for 30 degrees, you must change
30 degrees to radians
% expr sin(30 * $DEG2RAD)
0.499999999999
% expr cos(30 * $DEG2RAD)
0.866025403785

Post Building Techniques – Student Guide 8-15


Tcl basics for Post Builder

In Post Builder, numbers like those in the preceding example are


automatically output to your controller according to the word format you
defined for the relevant address. If you are outputting numbers to a print
report, you can format numbers to round them to a reasonable number of
decimal places.
Tcl implements a formatting statement that uses the same modifying symbols
as many other languages:
% format %1.3f [expr sin(30 * $DEG2RAD)]
0.500
% format %1.6f [expr cos(30 * $DEG2RAD)]
0.866025
% format %1.2f [expr cos(30 * $DEG2RAD)]
0.87

The following are some of the formatting rules:


• The charcter f sets a floating decimal point format.

• The number to the left of the decimal sets the minimum field width of the
output, including the decimal point.

• The number to the right of the decimal sets the number of decimal places
to show. The field is padded with zeros as necessary.

• A space character after the % inserts a blank space to the left of the output.

• A zero after the % pads the output with zeros on the left.

The number before the decimal refers to the minimum field width.
Remember, in Post Builder, variables named RAD2DEG and DEG2RAD are defined
and available to you.

8-16 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Activity: Tcl basics


In the Tcl basics for Post Builder section, do the following activity:
• Tcl basics

Post Building Techniques – Student Guide 8-17


Tcl basics for Post Builder

Tcl scripts
A Tcl script consists of a sequence of commands separated by either a "new
line" or a semicolon.
Comments are preceded by the "#". The following example illustrates the use
of a comment and the concept of a script:

Lines in scripts
set mom_pos(0) 12.4
set mom_pos(1) 28.3
set mom_pos(2) 0

is the same as
set mom_pos(0) 12.4; set mom_pos(1) 28.3; set mom_pos(2) 0

Comments in scripts
In the example, the lines beginning with # are comments. The Tcl interpreter
ignores comments except when they contain curly braces. Curly braces in
comments are counted for matching pairs of braces. This makes it awkward
to comment out sections of code for testing and debugging. You can work
around this issue with the if command. To do this, construct code similar
to the following:
8 # example showing how to comment out lines in a script
if {0} {
# code between the braces is never executed!
}

You can use the ; (semicolon) and the # (pound or number sign) characters
together to add a comment on the same line as a command.
set mom_pos(0) 12.4; # set the X coordinate

8-18 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl procedures
Procedures in Tcl are sets of commands that are analogous to subroutines in
other languages.
You can use common procedures throughout your programs. This makes it
easier to create and modify programs.
The following example illustrates the structure of a procedure:
proc procedureName {arg1 arg2 arg3 ...} {body}

If there is only one argument, you can omit the braces around the argument
list:
proc procedureName argument {body}

When you define a procedure in Post Builder, proc is inserted , the standard
prefix PB_CMD_ is added to the name automatically , and the braces around
the body are placed for you . The brace placement is styled for legibility.

Post Building Techniques – Student Guide 8-19


Tcl basics for Post Builder

The white spaces adjacent to braces are critical. If you omit a space,
your program crashes and you might get one of the following messages:
• No white space between first pair of braces:
proc TEST {} ( puts "testing 1 2 3" }
wrong # args: should be "proc name args body"

• No white space between first closing brace and second opening


brace:
proc TEST { }( puts "testing 1 2 3" }
extra characters after close-brace

• No white space after second opening brace:


proc TEST { } (puts "testing 1 2 3" }
wrong # args: should be "proc name args body"

• No white space before second closing brace:


proc TEST { } ( puts "testing 1 2 3"}
extra characters after close-quote

or
proc TEST { } (puts testing}
wrong # args: should be "proc name args body"

Use capital letters when you name procedures. Capitals, whether used
for the entire name or for the first word, make procedure names easier
to locate in scripts.
Use lowercase for variable names, so that you can easily distinguish
variables from procedures.
For example, in Post Builder, MOM_set_csys is a procedure, and
mom_csys_matrix is a variable.

In the command:
proc HI {} (puts "Hello World!"}
8
proc is the command to define a procedure.
HI is the name of the procedure.
There are no arguments.
Testing at the Tcl command prompt, you see the following:
% proc HI {} (puts "Hello World!"}
% HI
Hello World!
%

To call or execute the procedure, use the procedure name.

8-20 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

A procedure can have one or more arguments, and procedures return the
value of the last command they execute. For example:
% proc MULT {a b} {puts stdout "$a times $b equals [expr $a * $b]}
% MULT 3 4
3 times 4 equals 12
%

You can provide default values for variables by grouping the variable and the
default value in braces. For example:
% proc ECHO {{word "nothing to echo"}} {puts $word}
% ECHO fred
fred
% ECHO
nothing to echo

Arguments may contain local and global variables.


Example of a procedure:
#==================================
proc PB_CMD_ptp_size { } {
#==================================
# Output the current size of the ptp output file.
# Add this to the end of the End of Program event.
global ptp_file_name
global mom_sys_control_out
global mom_sys_control_in
set ci $mom_sys_control_in
set co $mom_sys_control_out
# Check the file size
MOM_close_output_file $ptp_file_name
set ptp_size [file size $ptp_file_name]
MOM_open_output_file $ptp_file_name
# Put a message for the file size in the ptp file
set ptp_feet [expr $ptp_size/120.]
MOM_output_literal "$co PTP file size = $ptp_size bytes\
[format "%5.1f" $ptp_feet] feet $ci"
}

Post Building Techniques – Student Guide 8-21


Tcl basics for Post Builder

Explicitly returning a value from a procedure


Procedures return the value of the last command they execute. You can use
program logic to return different values by determining which command
is executed last.
Use the return command with no arguments to return the value of a command.
return [expr $x / $y ]

Intermediate-level use of the return command


In Tcl, division with the expr command when either operand is a decimal
number returns a decimal number. If both operands are integers, you get
an integer result:
% expr 1.0 /2
0.5
% expr 1 / 2
0

If you divide by zero, you get a terse error message:


% expr 1 / 0
divide by zero

The following example procedure is designed to return a string as a formatted


decimal value regardless of any valid input, and it gives a more explicit error
message.
% proc DIV {x y) {
if [expr $y == 0] {
return -errorcode —code error \
"Division by zero is an illegal operation"
} else {
if [string is integer $x] {set x $x.0}
return [format "%1.4f" [expr $x / $y ]]
}
}

Examples using the DIV procedure after it is saved as div.tcl:


8 % source div.tcl
% DIV 1 2
0.5000
% DIV 1 0
Division by zero is an illegal operation

8-22 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Basic error handling


When Tcl reports an error at run time, your program crashes. To prevent
this, you can use the catch command, which works at run time. Returned
values are 1, or true, if an error occurs, and 0, or false, if no error occurs.
The catch command places error text in the variable that you specify. The
general format is:
catch {command | procedure} optional variablename

In the following command line examples, -code is an intermediate-level option


for the return command, and set errorInfo returns the most recent error text
and the name of the command or procedure that caused the error.
% proc OOPS {} {return —code 1 Mistake!}
% catch {OOPS} myInfo
1
% set myInfo
Mistake!
% set errorInfo
Mistake!
while executing
"OOPS"
%

Post Building Techniques – Student Guide 8-23


Tcl basics for Post Builder

Tcl input and output


Tcl maintains three standard input and output (I/O) channels: stdin for
standard input, stdout for standard output, and stderr for standard error. By
default, stdin accepts input from the keyboard and stdout and stderr output
text to the Tcl window.

puts
The puts command places its argument as a string of text to stdout, which is
usually the command window. The puts command has the following general
format:
puts [channel] string

The name of the output channel is optional. If only a single argument is


supplied, the argument is output to stdout.
% puts stdout "Hello, world!"
Hello, world!
% puts "Hello, world!"
Hello, world!

It is good programming practice to always supply stdout as the second


argument when you want the output to go to standard output. It avoids
confusion for anyone who has to interpret your code, and it assists with
debugging.

gets
The gets command reads a string of text from the keyboard that the user
terminates by pressing the Enter key. The terminating Enter character is not
kept and not counted. The gets command assigns the input to the specified
variable, and returns the number of characters it reads, not counting the
enter key.
% gets stdin title
King
4
% gets stdin name
8 Charles III
11
% puts stdout [concat $title $name]
King Charles III

8-24 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Combining puts and gets


The puts command has an option that is useful when you are prompting
for input:
puts —nonewline stdout "Please enter your name: "
flush stdout

You can follow the puts command with a gets command to prompt the user to
enter text on the same line as your prompt.
Example script:
# myio.tcl
proc MyIO {} {
global name; # make $name known outside this procedure
puts -nonewline stdout \
"Please enter your name: "; # issues the prompt
flush stdout; # required to output the incomplete line
gets stdin name; # accepts user typing until they press Enter
puts "Hello, $name"; # issues a personal greeting
}

You can use \ (backslash) before the newline character in procedures to


continue a long command over multiple lines.

source
The source command is another form of I/O. It reads a file into the current Tcl
session or program. It is used frequently in Post Builder. For example, near
the beginning of your posts, you see the source command used to retrieve a
library of standard procedures:
source ${cam_post_dir}ugpost_base.tcl

The following example shows a command prompt session to read and use
the procedure that is defined in the example for combining puts and gets in
a script:
% source myio.tcl; # reads procedure into session
% unset name; # make certain that name does not exist
% MyIO; # executes the procedure
Please enter your name: Shengmin 8
Hello, Shengmin

Post Building Techniques – Student Guide 8-25


Tcl basics for Post Builder

format
The format command lets you control the format in which output is written.
For example, you can control the number of decimal places, field width,
scientific notation, and so on. The general format for the command is:
format specification value1 value2 ...

The specification can contain literal output and formatting instructions.


Because the format string can contain white space, substitutions, and special
characters, it is common to place format specifications in double quotes. The
command operates by scanning the format string from left to right. Each
character from the format string is appended to the result string unless it
is a percent sign. If the character is % then the characters following the %
character are treated as a conversion specifier.
Here are some command line examples of using the format command for
floating point numbers.
% set PI [expr 2.0 * asin(1.0)]
3.14159265359
% puts [format "%1.4f" $PI]
3.1416

In the format specification "%1.4f":

• % introduces the rest of the string as a format specification

• The 1 sets the minimum field width for the output — we have several
characters, so the 1 does nothing in this case.

• The .4 specifies 4 decimal precision.

• The f tells the interpreter to expect a floating-point number.

The format string in the following example includes literal text.


% puts [format "Pi is approximately %1.4f" $PI]
Pi is approximately 3.1416

8-26 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

The following example introduces a wider-than-necessary field width, and


specifies padding with zeros:
% puts [format "%010.5" $PI]
0003.14159

In the format specifier "%010.5f":

• % introduces the rest of the string as a format specification.

• The first 0 instructs the command to pad the output field to the left with
zeros, if necessary.

• The 10 sets the minimum field width for the output at ten characters,
including the decimal point and the decimal digits.

• The .5 specifies a 5 decimal precision. The decimal point and decimal


digits take up six characters of the ten-character width, leaving 4
characters for the digit 3 and padding characters.

• The f tells the interpreter to expect a floating-point number.

The interpreter does its one round of variable substitution before it analyzes
the format string. You can place format specifications in variables and use
the variables in the format specification.
% set myFormat %10.5f
%10.5f
# The % in the previous line is not the prompt;
# it is part of the value returned by the format statement.
% format $myFormat $PI
3.14159
# Notice the leading spaces.
# The field is 10 characters wide.

Please refer to the Tcl documentation for the complete list of formatting
capabilities and the corresponding specifications.

Post Building Techniques – Student Guide 8-27


Tcl basics for Post Builder

scan
The scan command lets you format text input to your specifications. When
you read a line of text from stdin, or from a file, you often want to set one or
more variables. The general format of the scan command is:
scan text_string format_specifcation var 1 var2 ...

The scan command uses the following format specifications:


• f — the input field must be a decimal number with an optional sign.

• d — the input field must be an integer in the decimal number system.

• s — the input field consists of all the characters up to the next white-space
character.

• [characters] — the input field consists of the characters within the


brackets in any order. You can use the dash to represent a range of
characters.

• [^characters] — the input field consists of characters that do not match


any of the characters in the brackets.

Please refer to the Tcl documentation for the complete list of formatting
capabilities and the corresponding specifications.
The scan command returns the number of matches it makes from an input
string:
% scan "abc" %s result
1
% set result
abc

Enclose multiple match patterns in braces so that the specification string is


recognized as a single word.
The following example matches uppercase letters, a string, lowercase letters,
and an integer, and sets four variables in an array:
8 % set claim "NX is number 1"
NX is number 1
% scan $claim {%[A-Z] %s %[a-z] %d} r(0) r(1) r(2) r(3)
4
% array get r
0 NX 1 is 2 number 3 1

Match anything but uppercase Z and set one variable:


% scan $claim {%[^Z]} great
1
% set great
NX is number 1

8-28 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Match anything but a space character and set one variable:


% scan $claim {%[^ ]} product
1
%set product
NX

The following example matches a string, anything but a space character, the
letters "r e n b u m" in any order, and an integer, and sets four variables:
% scan $claim {%s %[^ ] %[renbum] %d} a b c d
4
% set a
NX
% set b
is
% set c
number
% set d
1

The scan command returns zero if there are no matches:


% scan $claim {%[AB_34]} nothing
0
% set nothing
can’t read "nothing": no such variable

The following shows how the scan command is used in ugpost_base.tcl:


set a [scan $mom_tool_use($nn,0) %d tn]

Inside the square brackets, the variable tn is created or modified if a value


taken from an array called $mom_tool_use is recognized as a decimal integer.
The element from the array is determined by the row index specified by the
value of variable $nn, and by the column index "0".
Outside the square brackets, a is set to the number of matches returned by
the scan statement. If a is 1, then tn contains a tool number from the array
location $nn, 0. If a is 0, then either tn is not set, or the value in tn is from a
previous assignment.
The total effect is to attempt to assign a tool number out of the array
$mom_tool_use, and set a flag a to signal success or failure.
8

Post Building Techniques – Student Guide 8-29


Tcl basics for Post Builder

Working with files in Tcl


File management is an essential component of postprocessing. In addition to
the basic function of writing NC output files, warnings files, and listing files,
you can do file-related tasks like the following:
• Write to or append to a log file

• Write a documentation file

• Read data files

• Delete files

To manage files, you can:


• Use Tcl built-in file commands.

• Call MOM procedures in Post Builder.

I/O channels
In file management, you use I/O channels that you create to communicate
with files. The channel is called a file identifier, and you store it in a variable.
You can use the variable in the same context as you would use stdout, stdin,
or stderr.
Refer to Tcl documentation for a more advanced type of channel that is
beyond the scope of this class.

file exists
Use the file exists command to check whether a file exists before you
attempt to work with it.
Command line example:
% file exists tclsh.exe
1
% file exists "nonexistent_file"
8 0

Program example:
if { [file exists "$result_file"]==1 } {
# work with the file named by $result_file
}

open
The open command opens a file and returns an identifier. The general format
for the command is:
open filename access permissions

8-30 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

filename
Identifies an existing file. Include the full operating system path if the
file is not in the current directory.
access
Describes the type of access of which the channel is capable. Unless
otherwise specified, the file must exist. The following are the standard
flags for access. Advanced users may use the POSIX access flags, not
described here.
r Opens the file for reading.
r+ Opens the file for reading and writing.
w Opens the file for writing. Truncate the file if it exists.
Create it if it does not exist.
w+ Opens the file for reading and writing. Truncate the
file if it exists. Create it if it does not exist.
a Opens the file to append data. Data written is
appended to the end of the file.
a+ Opens the file for reading and to append data. Data
written is appended to the end of the file.
permissions
This argument applies only to Linux systems. Use the format described in
the man pages for the chmod command.

Command line example:


% set fid [open "scratch.txt" w]
file633c10

In the previous example, the string file633c10 contains a random hexadecimal


number that is guaranteed to be unique.

Post Building Techniques – Student Guide 8-31


Tcl basics for Post Builder

The following example from a Post Builder post shows a results file being
opened for reading:
if { [file exists "$result_file"] } {
set fid [open "$result_file" r]
# work with the file
}

In the example program:


• $fid can be used to identify the file in an argument to the read command.

• The double quotes are inserted automatically by Post Builder in case


the value being retrieved, a file name, has a space in it. If you are
programming the file name directly and you know that the name does not
contain a space, you do not need the double quotes.

close
Use the close command with a file identifier to close an I/O stream.
close $fid

puts
Use the puts command without options to write a line of output and a newline
character to a file that is open for writing.
puts $fid $myString

You can force output without a newline character using the -nonewline option
before the first argument.
puts —nonewline $fid $myString
% set fid [open testfile.txt w]
file 1c7d770
% puts $fid "My name is Fred."
% puts -nonewline $fid "I write "
% puts $fid "postprocessors."
% close $fid
% set fid [open "testfile.txt" r]
file1c7d7e8
8 % read $fid
My name is Fred.
I write postprocessors.

gets
Use the gets command to read a line of input from a file that is open for
reading and discard the trailing newline character. Successive use of the gets
command reads the file line by line. There are subtleties to distinguishing
between blank lines and the end of file when gets is used with only one
argument. In this introduction the examples have two arguments:
gets $channel line

8-32 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

In the two-argument syntax, gets returns the number of characters read, or


0 for a blank line. With two arguments, when the end of the file is reached,
gets returns –1.

The following example is used in a procedure.


while { [gets $sub line] >=0 } {
MOM_output_literal $line
}
close $sub

MOM_output_literal is a procedure that writes a list of literal characters and


variables held in the variable $line, without a sequence number.
In the loop condition, the return from gets $sub line is compared to 0 or
greater, because the file could include blank lines for which gets returns 0.
When the end of file is reached, gets returns –1, the loop terminates, and the
file is closed. The net effect is to copy everything in $sub to the NC output file.

read

The read command can be more efficient that gets because it returns a block
of data, which is often all of the remaining data in the specified file.
If you do not use any options, read returns all of the data remaining in the
file, formatted in the same way as it is in the file.
You can use one of the following options, but you cannot combine them.
read —nonewline file_id
The –nonewline option discards trailing newline characters in each line
of text.
read file_id numchars
The numchars argument is an integer number. It modifies the read
command to read the specified number of number of characters, or to
the end of the file if there are not the specified number of characters
remaining. For example, read $fid 80 reads 80 characters from the file
identified by $fid.
8
split
The split command splits a text string into a Tcl list. The basic syntax is:
split string split_characters

Post Building Techniques – Student Guide 8-33


Tcl basics for Post Builder

The string specified by the first argument is divided into a list element
at every character in the specified splitting characters. A single splitting
character is not enclosed in double quotes; however, several characters must
be enclosed in double quotes. The splitting characters are discarded, and
braces are inserted as needed.
% split "my.long.file.name" .
my long file name
% split "Aqlittlebpuzzlecfordyou" "qbcd"
A little puzzle for you

You can specify a null splitting character set to divide a string into characters:
% split "Hello, world!" {}
H e l l o , { } w o r l d !

Note that the space character is grouped inside braces in the output. The
split command groups any word that contains spaces within braces.

When the string being split is the contents of a file, for example, a big string
returned by the basic read command, the special character \n, the newline
character, is used to split the lines into list words:
foreach line [split [read $fid] \n] (
# do something with $line
}

The foreach command is explained under program flow structures.

Working with file specifications


The following operations do not require that the file in filename exists, except
as specified.
file dirname Returns the path to the file identified by filename. If the
filename path is the current directory, on Windows and Linux the
single character ‘.’ is returned, and on Mac the character
‘:’ is returned.
On Windows, you must escape any backslash characters
in the path, or simply convert them to forward slashes.
% file dirname "tclsh.exe"
8 .
% file dirname "C:\\Windows\\system.ini"
C:/Windows
% file dirname "C:/Windows/system.ini"
C:/Windows

Note that the path returned uses the forward slash, as


in the Unix or Linux style.
file isdirectory Returns 1 if filename is a directory, or returns 0 otherwise.
filename % file isdirectory "C:/Windows"
1
% file isdirectory "tclsh.exe"
0

8-34 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

file extension Returns all of the characters in the text string filename
filename after and including the last dot in the last element of
filename. Elements are strings separated by the / (slash)
character. If there is no dot in the last element of filename
then an empty string is returned.
% file extension "tclsh.exe"
.exe
% set fid [open "fred" w]
file1bc7bd8
% file exists fred
1
% set myext [file extension fred]
% info exists myext
1
% string length $myext
0

You can determine if a variable contains an empty


string by checking that the variable name is
defined, and that the string length of the variable
value is zero characters.

file normalize Removes all relative path characters the text string
filename filename and returns the full operating system path to the
file identified by filename. On Windows, the backslash in
the path is replaced by the forward slash.
% file normalize "./tclsh.exe"
C:/Tcl/bin/tclsh.exe

file size Returns a decimal string giving the size of the file
filename identified by filename in bytes. If the identified file does
not exist or if the size of the identified file cannot be
queried, an error occurs.
% file size "tclsh.exe"
20480

Note that the size of tclsh.exe varies depending on


platform and version.
file tail Returns all of the characters in the text string filename
8
filename after the last directory separator. If filename contains no
separators, the command returns filename.
% file tail "C:/Windows/system.ini"
system.ini
% file tail "tclsh.exe"
tclsh.exe
% file tail "C:/Nosuchfolder/nosuchfile.txt"
nosuchfile.txt

See the Tcl documentation for a list of the many other arguments that you
can use with the file command.

Post Building Techniques – Student Guide 8-35


Tcl basics for Post Builder

Tests for permissions


The file exists command may not give you enough information. For
example, you may need to know if the file is readable and writable for the
current user, or if the current user is the operating system owner of the file.
file readable Returns 1 if the current user has read permission to the
filename file identified by filename, or returns 0 otherwise.
file writable Returns 1 if the current user has write permission to the
filename file identified by filename, or returns 0 otherwise.
file owned Returns 1 if the current user owns the file identified by
filename filename,or returns 0 otherwise.

Intermediate-level file commands


Intermediate-level and advanced-level programmers may refer to the Tcl
documentation for information about eof, seek, tell, and glob.

8-36 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl string commands


Strings, or sequences of text characters, are the only data type that Tcl stores.
As you might expect, the Tcl string command has several arguments that are
useful to investigate and manipulate text strings.
Several arguments specify an index or position in the string. Tcl follows
the common convention of numbering characters in the string beginning
with zero; thus, the character with index 1 is actually the second character
in the string, and the last character has an index that is one less than the
number of characters in the string.
There are other commands that work with strings, for example the concat
command splices its arguments together to form one string.
It is not necessary to quote a string argument if it consists of a single word.
To view a list of valid arguments for the string command, use an invalid
argument for the command at the Tcl command prompt.
% string bad
bad option "bad": must be bytelength, compare, equal, first,
index, is, last, length, map, match, range, repeat, replace,
tolower, toupper, totitle, trim, trimleft, trimright,
wordend, or wordstart

string length str Returns the number of characters in the string str. In
UTF-8 encoding, characters may require two or three
bytes. This explains why string bytelength str is also
available.
% string length "abcdef"
6
% set str abcdef
abcdef
% string length $str
6
% string length abcdef
6

string tolower Returns the lowercase conversion of str.


str % set str ABC123DEF
ABC123DEF
% string tolower $str
8
abc123def

The string tolower command has optional arguments.


You can specify the indices of the first and last characters
to convert, or you can specify one index, to convert only
the specified character. Remember that string indices
start at 0.
% string tolower $str 0 1
abC123DEF
% string tolower $str 7
ABC123DeF

Post Building Techniques – Student Guide 8-37


Tcl basics for Post Builder

string toupper Returns the uppercase conversion of str. The syntax is


str the same as string tolower.
% set myUpper [string toupper "g17 g20 g40"]
G17 G20 G40
% set myUpper
G15 G20 G40

string range str Returns the range of characters in the string between the
first last first and last integer indices. This is the Tcl equivalent
of the substring command in other languages. No error
occurs if last is greater than the last valid index.
% set home "G28 G91 X0 Y0 Z0"
G28 G91 X0 Y0 Z0
% string range $home 0 6
G28 G91
% set newHome [concat [string range $home 0 6] \
[string range $home 13 15]]
G28 G91 Z0

string trim str Removes all whitespace characters from the beginning
and end of str. The trim argument is useful to get rid of
unwanted spaces, tabs, and so on from user input.
% set bulky "\t abc \t"
abc
% string length $bulky
11
% set slim [string trim $bulky]
abc
% string length $slim
3

string trim str Removes any or all of the specified characters if they
characters appear in any order at the beginning or end of str.
% string trim ababcdebaba ab
cde

string trimleft Work like string trim except that they remove whitespace
str and string or optional characters only from the left or right of the
trimright str string.
8 These commands are useful when string trim removes
characters that you want to keep:
% string trim "N3670 G01 X100.35 Y50.10 F100" "N 0123456789"
G01 X100.35 Y50.10 F

Although the intention was to remove any possible


sequence number, the value of the feed rate word is also
removed! The string trimleft command avoids this
problem:
% string trimleft "N3670 G01 X100.35 Y50.10 F100" "N 012345678
G01 X100.35 Y50.10 F100

8-38 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

string is double There are several similar commands to see what kind
and string is of value is represented by a string. Arguments include
double —strict alpha, boolean, false, true, and several more.

These commands return 1 if the string is a valid member


of the specified class, otherwise it returns 0. If the
parameter -strict is specified, an empty string returns 0,
otherwise, an empty string always returns 1.
% string trim "N3670 G01 X100.35 Y50.10 F100" "N 0123456789"
G01 X100.35 Y50.10 F

Although the intention was to remove any possible


sequence number, the value of the feed rate word is also
removed! The string trimleft command avoids this
problem:
% string is double 10.0
1
% string is double 25
1
% string is double "fred"
0
% string is double ""
1
% string is double —strict ""
0

Post Building Techniques – Student Guide 8-39


Tcl basics for Post Builder

Activity: Construct a simple procedure


In the Tcl basics for Post Builder section, do the following activity:
• Construct a simple procedure

8-40 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Program flow control


Tcl has flow control commands for conditional execution or branching, and
for looping. In branching, you define logic to control which statements are
executed. In looping, you set a test to determine how many times a loop of
commands is repeated.

if then else
The branching structure uses the following general command formats.
if example:
if {test} {
# commands to execute if the test result is true
}

if else example:
if {test} {
# commands to execute if the test result is true
} else {
# commands to execute if the test result is false
}

if elseif else example:


if {test_1} {
# commands to execute if the test_1 result is true
} elseif {test_2}
# commands to execute if the test_2 result is true
} else {
# commands to execute if both test results are false
}

The then command is optional in Tcl. If the test is a long string of code, use
then to make your code easier to read.
if {long test statement, perhaps more than 1 line}
then {
# commands to execute if the test returns true
}

The white space around the braces in if commands is critical, but not as
critical is it is with procedure syntax. You must place white space after a 8
closing brace. The error message is extra characters after close-brace. The
constructions } else { and } elseif { must be on the same line of code, and
spaced. Error messages include invalid command name else{ and invalid
command name elseif{.

Post Building Techniques – Student Guide 8-41


Tcl basics for Post Builder

The test can be a command that returns an integer, or a logical comparison.


Remember that Tcl is a string-based language, so you need to be mindful of
formatting and tolerances when you compare numbers.
Operator Comparison
== equal
!= not equal
> greater than
>= greater than or equal
< less than
<= less than or equal

You can combine logical statements with the following logical operators:
Tcl Operator Logical meaning
&& and
|| or

Programming example of branching with multiple tests:


if {$mom_sys_cir_vector == "Vector - Arc Center to Start"} {
set mom_prev_pos($cir_index) 0.0
set mom_pos_arc_center($cir_index) $pitch
} elseif {$mom_sys_cir_vector == "Vector - Arc Start to Center"}{
set mom_prev_pos($cir_index) $pitch
set mom_pos_arc_center($cir_index) 0.0
} elseif {$mom_sys_cir_vector == "Unsigned Vector - Arc Center / to Start"} {
set mom_prev_pos($cir_index) 0.0
set mom_pos_arc_center($cir_index) $pitch
} elseif {$mom_sys_cir_vector == "Absolute Arc Center"} {
set mom_pos_arc_center($cir_index) $pitch
}
}

8-42 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

switch
Use the switch command when you have a series of branching tests against
the same variable. The switch code is easier to read than a long series of
if, elseif, elseif, else commands.

The switch command has the following general syntax:


switch —options variablename value1 body1 value2 body2 ...

Programming example:
switch $mom_rotation_mode {
NONE {
set angle $mom_rotation_angle
set mode 0
}
ATANGLE {
set angle $mom_rotation_angle
set mode 0
}
ABSOLUTE {
set angle $mom_rotation_angle
set mode 1
}
INCREMENTAL {
set angle [expr $mom_pos($axis) + $mom_rotation_angle]
set mode 0
}
}

Do not place comments at the same level as the matching values or


patterns, as the interpreter will try to interpret the comment as a value
to test for a match.
switch $mom_rotation_mode {
# a comment in this position will confuse the Tcl interpreter
NONE {
set angle $mom_rotation_angle
set mode 0
}

Place comments only inside the body of statements to execute for a


matching value or pattern.
switch $mom_rotation_mode {
NONE {
8
# a comment in this position is acceptable
set angle $mom_rotation_angle
set mode 0
}

There are no examples of the switch options here because the options are part
of advanced applications based on pattern matching.

Post Building Techniques – Student Guide 8-43


Tcl basics for Post Builder

while
The Tcl while command has the following general format:
while test commandBody

Program example:
while {[expr $a4-$mom_kin_4th_axis_min_limit] > 360.0} {
set a4 [expr $a4-360.0]
}

If the variable a4 is larger than 360, this loop executes, subtracting 360 from
a4 on each iteration, until a4 is less than 360. Note that if a4 is ever exactly
360, the loop is going to execute one last time, because the test comparison
operator is < (less than), and not <= (less than or equal to).
The loop executes until the test is no longer true. You must do something in
the loop to update the test criteria, or the loop will never end.
while {1 == 1} {
# loop never exits, unless you use a break command.
}

You must make sure the test can be true, or the command body is never
executed.
while {1 == 0} {
# never executed because the test is always false.
}

If the loop condition is a counter, it is common to use the incr command to


update the counter.

incr
Use the incr command to update a loop counter variable by adding 1 to the
value of the variable.
Command line example:
% set i 0
0
% incr i
1
8 % incr i
2

Note that the incr command expects the name of a variable as an argument.
You do not use the $ prefix.

for
The for command combines setting an initial loop test variable, specifying
the test, and updating the test variable in one compact statement. The
general format is:
for {start} {test} {next} { commandBody }

8-44 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

The steps are executed in the following order: start, test, commandBody, next,
test, commandBody, next, test, commandBody, and so on.

Program example:
for {set i 0} {$i < $n} {incr i} {
set v2($i) $v1($i)
}
}

In the example:
• The start condition sets a loop counter variable, i, to zero.

• In the test, the current value of i is compared to a value stored in n.


Notice that for the comparison, the dollar sign prefix is required.

• In the update, incr i, the counter variable i is incremented by one.

• Within the body of the loop, the value of i is used as an index into arrays
v1and v2.

The net result of the example loop is that the first n elements, specified by $n,
of array v1 are copied to array v2. The values of i range from 0 to n–1. This is
typical coding for arrays that start with index 0. When i is equal to n, the test
fails and the program moves on the next line after the loop body.

foreach

Use the foreach command to set one or more variables to values specified in
a list of values, using each value in turn as the loop body executes. This
might be considered as an intermediate-level programming method; however,
you will encounter it frequently in postprocessors. The basic syntax for only
one variable is:
foreach variable {list} {commandbody}

Command line example:


% foreach j {2 6 24} {puts "$j squared is [expr $j * $j]"}
2 squared is 4
8
6 squared is 36
24 squared is 576

Program example:
foreach address $address_list {
catch {MOM_set_address_format $address AbsCoord_mm}
}

The example repeatedly calls a procedure, MOM_set_address_format, which in


turn sets each address in a list of addresses to the format represented by
the second argument, AbsCoord_mm.

Post Building Techniques – Student Guide 8-45


Tcl basics for Post Builder

In this context, catch returns 1 if an error occurs. There is no code to save


the error message or act upon the returned value from catch; so, in effect,
errors in the loop are ignored.
For intermediate-level programmers, the foreach command lets you specify
multiple variables to assign values from the supplied list:
foreach {list of variables} {list of values} {commandBody}

Command line example to work with pairs of array indices and values:
% #preparation
% set inp(x) 1.234
1.234
% set inp(y) 2.345
2.345
% set inp(z) 3.456
3.456
% result demonstration
% array get inp
x 1.234 y 2.345 z 3.456
% example of foreach (on two lines):
% foreach {index value} [array get inp] \
{ puts "Element index $index is $value" }
Element index x is 1.234
Element index y is 2.345
Element index z is 3.456

A search of Tcl programs in the NX 8 Post Builder folders did not reveal any
examples of intermediate-level or advanced-level uses of foreach.
At the most advanced level, the foreach command can interpret multiple
pairs of variable and value lists. The command iterates until all variables are
used from all variable lists.

break
You can gain additional control over your while, for, and foreach program
loops with the break and continue commands.
Use the break command to exit immediately from the loop that contains it.

8-46 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

In the following program example from ugpost_base.tcl, the for loop iterates
through pairs of vector components from vector u, the vector being tested,
to the corresponding components of vector v, a zero vector defined early in
the procedure. Inside the loop, if any element of u is within an optional
tolerance of vector v, the return value is_equal is set to 0, or false, and the
break statement is executed, stopping any further testing.
# VEC3_is_zero(u,tol) (|| u || < tol) Is vector zero?
proc VEC3_is_zero {u} {
upvar $u u1
set v1(0) 0.0 ; set v1(1) 0.0 ; set v1(2) 0.0
set is_equal 1
for {set ii 0} {$ii < 3} {incr ii} {
if {![EQ_is_equal $u1($ii) $v1($ii)]} {
set is_equal 0
break
}
}
return $is_equal
}

More explanations:
The value of is_equal is set to one, or true, before the loop, so that true is
returned if nothing happens to change it. This ensures that the procedure
returns a defined value.
The upvar command, in the basic form shown here, lets you associate a
variable name in the calling procedure with a local variable. The variable
named $u, an array of vector components in the calling procedure, is
associated with the variable u1 in the VEC3_is_zero procedure.
The procedure EQ_is_equal is one of a family of procedures in Post Builder that
compare numeric values within a tolerance. For example, the Tcl operator = =
would do a string comparison of 1.99999999999 and 2.0 and report that they
are not equal. EQ_is_equal compares within a default or specified tolerance,
and reports that as far as the postprocessor is concerned, the numbers are
close enough to be considered equal.

continue 8
Use the continue command to skip the rest of the current loop iteration, and
jump to the next iteration of the loop that contains the continue command.
The syntax, in context of a dummy loop, is shown in the following:
for {start} {test} {next} {
# do some processing for current loop variable
...# test something
if [test] {
# skip further processing, jump to next
continue
}
# further processing for current loop variable value

Post Building Techniques – Student Guide 8-47


Tcl basics for Post Builder

exit
Use the exit command to stop the execution of your program. Advanced users
may include an optional error code.
# test something
if [test] {
# stop the program
exit
if [another test] {
# end the program with an error code
exit 2
}

8-48 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Activity: Program flow control


In the Tcl basics for Post Builder section, do the following activity:
• Tcl flow constructs

Post Building Techniques – Student Guide 8-49


Tcl basics for Post Builder

Regular expressions
Regular expressions are a pattern matching syntax common to many
languages that have their origins in Unix.
Regular expressions use their own syntax to match patterns in character
strings. In your postprocessing, you might find uses for regular expressions in
advanced uses of the switch command, the regexp command, and the regsub
command.
For complete information on regular expressions, see Practical Programming
in Tcl and Tk.

Common syntax elements


The following is a summary of some common patterns in regular expression
syntax.
. Matches any single character.
* Matches zero or more instances of the preceding match
pattern item. For example, .* matches zero or more
instances of any characters.
+ Matches one or more instances of the preceding match
pattern item. For example, 0+ matches one or more zeros.
? Matches zero or one instances of the preceding match
pattern item. For example, 0? matches no zeros or exactly
one zero.
( ) Groups a sub-pattern, which is treated as a single match
pattern item for the match characters described. For
example, (abc)+ matches one or more repetitions of abc.
| Designates alternate patterns. For example (a | b)
matches either a or b.
^ When first, the pattern must appear at the beginning
8 of the string that is being searched. Also used as a
negation operator in character groups. For example,
{^G.*} matches strings that start with G.

$ When last, the pattern must appear at the end of the


string that is being searched. For example, {.*pt$}
matches strings that end with pt.

8-50 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

regexp
Use regexp to determine whether a pattern can be matched in a string. The
command returns 1, or true, if the pattern is found, and 0, or false, if it
is not found.
The syntax common in ugpost_base.tcl is as follows:
regexp {matchPattern} stringToSearch

Typical lines returned by a search for regexp in ugpost_base.tcl:


if {[regexp "MOM_msys" $mom_warning_info] == 1} {
return
}
if {[regexp "MOM_lintol" $mom_warning_info] == 1} {
return
}

The match patterns are simple literal strings so the programmer was not
forced to use curly braces around MOM_lintol; however, it is a good idea to use
the braces in your code at all times, to help you to develop safe programming
habits.
The return value of regexp is compared to 1. If the pattern is present in the
string represented by $mom_warning_info, regexp returns 1, the test returns
true, and the body of the if command is executed. The body of the if command
is the return command, which ends the procedure that contains the example
code and returns the program flow to the next line of the calling procedure.

Post Building Techniques – Student Guide 8-51


Tcl basics for Post Builder

regsub
Use the regsub command to substitute a specified set of characters for a
match pattern found in a string. For example, in a very simple application,
you could use it to exchange the slash and backslash characters in a file path
specification. The general format is:
regsub —options {matchPattern} stringToSearch stringToSubstitute variableName

The most common option is -all, which causes every match for matchPattern
to be replaced by stringToSubstitute. Without -all, only the first instance of
the match would be replaced.
Command line example:
% regsub {[\\]} "C:\\tcl\\bin\\tclsh.exe" "/" myOutput
1
% set myOutput
C:/tcl\bin\tclsh.exe
% regsub -all {[\\]} "C:\\tcl\\bin\\tclsh.exe" "/" myOutput
2
% set myOutput
C:/tcl/bin/tclsh.exe

In the following example code from ugpost_base.tcl, we assume that the


controller for which we are postprocessing requires different control-in
and control-out characters, or comment delimiters, than the parentheses
used in Fanuc-like controllers. The control-in and control-out characters
for the controller are specified by the strings $mom_sys_control_in and
$mom_sys_control_out, respectively.
regsub -all {[)]} $text_string $mom_sys_control_in text_string
regsub -all {[(]} $text_string $mom_sys_control_out text_string

The effect of the two lines is to substitute all control-in and control-out
characters in $text_string with the control-in and control-out characters that
the controller requires. The string being searched and the output string can
be referenced by the same variable name.

8-52 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Tcl and NX
Extensions of Tcl were developed for specific applications such as NX Post,
Shop Documentation, Process Assistants, Libraries and User Defined
Features.
Tcl can call NX Open routines, formerly called user function or UFUNC, and
NX Open routines can call GRIP routines. Tcl is easy to use and is extensible
using the C language.
You can access Tcl code through CAM modules such as NX Post or Shop
Documentation.
The custom command capability in Post Builder allows you to insert custom
Tcl procedures into a postprocessor. There is a library of procedures in various
folders under ...\Siemens\NX 8.0\MACH\resource.
Common procedures are provided, and new procedures are added to each
release.

Post Building Techniques – Student Guide 8-53


Tcl basics for Post Builder

Tcl reference manuals


For more programming examples, tips on error trapping and debugging,
deeper explanations of commands and syntax, and advanced usage, refer to
one or more of the following:
• Practical Programming in Tcl and Tk by Brent B. Welch ISBN
0-13-616830-3

• SAMS Teach Yourself Tcl/Tk by Venkat V.S.S. Sastry & Lakshmi Sastry
IBSN 0-672-31749-4

• Tcl/Tk Programmer’s Reference by Christopher Nelson ISBN


0-07-212004-5

8-54 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Tcl basics for Post Builder

Summary: Tcl basics for Post Builder


Summary: Tcl is a scripting language that is extensively used in Post and
Post Builder. The Custom Command feature of the Post Builder allows the
insertion of custom Tcl procedures that can be created for applications such as
custom output formats or specific custom machine tool/controller functionality.
The following Tcl functionality is used in the creation of Custom Commands:
• Variables

• Mathematical expressions

• Procedures

• Input and output statements

• Flow control structures

Post Building Techniques – Student Guide 8-55


8
Lesson

9 Custom commands

Purpose
This lesson describes the procedures for customizing postprocessors using the
NX Post Builder application.

Objective
After you complete this lesson, you will be able to:
• Use custom commands to customize Post Builder output files.

Post Building Techniques – Student Guide 9-1


Custom commands

Post processor development process

Gather machine tool specifications


and controller parameters from Test the postprocessor output
manufacturer manuals
Deliver the functional post
Enter parameters in Post Builder
processor

9-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Custom commands

Custom Command tab


Custom commands generate the output that you specify. Define custom
commands when the output that you require is not available. For example,
you can define a custom header at the beginning of your output program.
Custom procedures appear in the list of commands that you can place with
any event marker on the Program tab.

When you define a custom command, you complete it by adding Tcl code.
You can import the command from a provided library or define your own
code. Post Builder:
• Provides a default procedure name.

• Provides the correct syntax, including the braces that enclose the body
of the procedure.

• Checks the syntax of the code you enter and displays syntax error
messages for your code automatically.

Click Export to create your own library file. You can specify one or more
custom commands that you can later import into other postprocessors.
You can check for unknown commands, unknown blocks, unknown addresses
and unknown formats for validation by choosing Options®Validate Custom
Commands.

Post Building Techniques – Student Guide 9-3


Custom commands

Importing custom commands


1. Click Import.

Library procedures usually contain comments that provide the necessary


instructions and a summary of how the procedure works.

2. In the Select a File dialog box, navigate to the provided library or to a


location where you store your own custom command libraries.
The custom command library is in the
${UGII_BASE_DIR}\postbuild\pblib\custom_command folder. Library
files begin with the prefix pb_cmd_ and have the extension .tcl.

3. Select a file and click OK.


The Tcl file is checked for syntax errors and for new commands.

4. In the Import Commands from file name dialog box, select one or more
procedures to import.
Only procedure names that you do not have defined in your post are
shown. Click Deselect All to clear all selections, and then double-click the
ones that you want to select. Click Select All to select all procedures.

5. Click OK to import the commands.

9-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Custom commands

Activity: Custom commands


In the Customize a postprocessor with Post Builder section, do the following
activities:
• Custom commands

• Output the head name for each operation

Post Building Techniques – Student Guide 9-5


Custom commands

Summary: Custom commands


Custom commands let you use predefined procedures or your own library
procedures that allow for custom output. Custom commands can be:
• Retrieved from a provided library.

• Created to meet individual machine tool custom output.

• Created, modified and saved in a library file for use in other postprocessors.

9-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Lesson

10 User defined events and user


defined cycles

Purpose
This lesson describes the process for creating user-defined events, user-defined
cycles, and their associated event handlers in Post Builder, and the steps
needed to use these events in NX.

Objective
After you complete this lesson, you will be able to:
• Create, modify, and use user-defined events (UDEs).

• Create, modify, and use user-defined cycles.

10
Post Building Techniques – Student Guide 10-1
User defined events and user defined cycles

User-defined events
A user-defined event (UDE) is a custom machine control event that you add to
operations and CAM parent objects in NX to capture information that you
cannot configure in a default tool path. For example, you can add output such
as a custom clamping code or a fixture positioning code by defining a UDE.
You can make this information available for use in NX by defining the event in
your postprocessor using Post Builder. Without Post Builder and NX Post, you
would have to write the .cdl file and interpret the NC output in your own post.

10
10-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

UDEs in Post Builder


To make UDEs available for use in NX, you use the following objects in Post
Builder:
• Machine control events. The definition of these events includes the
required variables and the user interface specification. These events are
passed to NX in a file with the .cdl extension. You must configure the .cdl
file to be read in the NX Manufacturing environment so that your events
are visible in NX.

• Existing postprocessor words, such as G_spin or dwell.

• An event handler. An event handler is custom Tcl code that is executed


during output when a user adds the corresponding event to an NX tool
path. Event handler code is saved with the post. An event handler must
interpret the value of the variables that you define and create the machine
controller output that you require.

User-defined events appear on the Machine Control page in your post. You
can distinguish between pre–defined events and user-defined events
by their color. You manage pre-defined events making settings and choosing
options in default NX operation dialog boxes. You must add user-defined
events to NX operations or CAM parent objects as start events or end events.

10
Post Building Techniques – Student Guide 10-3
User defined events and user defined cycles

UDEs in NX
In NX, you can attach UDEs as object start events or object end events for
the following:
• An operation

• A CAM parent object: program, method, machine tool, or geometry.

Many user-defined events are supplied with NX, for example, events to
output the following:
• Custom coolant options

• Clamping accessory commands

• Operator messages

10
10-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

User Defined Cycles


A user-defined cycle or UDC lets you enhance an existing canned machine
cycle by adding additional parameters to accommodate add-on features for
machines that support them, for example, the Siemens Sinumerik
840D. These cycles are currently applicable only to hole-making operations.

User-defined cycles appear on the Canned Cycles page in your post. You
can distinguish between pre-defined cycles and user-defined cycles
by their color.

Some user-defined cycles are included with NX, but they are not configured
by default. For example, to support machine cycles that are defined in
the template post for your Siemens Sinumerik 840D controller, you must
configure your machining environment to read the Siemens_Cycles.cdl file.

10
Post Building Techniques – Student Guide 10-5
User defined events and user defined cycles

User-defined event .cdl file


The interface for user-defined events and user-defined cycles and
the associated variables are defined in the ude.cdl file located in the
$UGII_BASE_DIR\mach\resource\user_def_event\ folder. You can specify
this folder with the environment variable $UGII_CAM_USER_DEF_EVENT_DIR.
In the ude.cdl file or your custom .cdl file, you can define user-defined events
with the following syntax:
EVENT <name>
{
POST_EVENT <post_name>
UI_LABEL <ui_name>
UI_HELP "help button label"
"help file url"
# you can specify one or more of the following categories
CATEGORY Mill | Drill | Lathe | WEDM
PARAM <param_name_1>
{
TYPE i | d | s | o | b | p | v | g | l
DEFVAL <default value as string>
TOGGLE Off | On
OPTIONS <string1, string2, string3....... >
UI_LABEL <param_ui_name>
}
PARAM <param_name_2>
{
}
PARAM <param_name_3>
{
}
}

10
10-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

Keywords in the .cdl file


EVENT<name>
Defines an event with the name that you enter after the EVENT keyword.
POST_EVENT <post_name>
(Optional) Writes the event to the NC output file with the name shown
after the POST_EVENT keyword. If this keyword is not specified, NX outputs
the post event name specified after the EVENT keyword.
UI_LABEL <ui_name>
(Optional) Specifies the title of the NX dialog box for the event. If this
keyword is not specified, NX outputs the post event name specified after
the EVENT keyword.
UI_HELP
(Optional) Specifies two text strings. The first string is the title that

appears beside the help button in the dialog box that appears in NX
when a user adds your event. The second string is a URL that points to
an HTML file that provides useful information about your event. You
need not place the two strings on the same line.
The format for a URL that points to a local file is
"file://localhost/path".

The two slashes that precede the local host name are required.
For example, if the file is on the user’s computer, the URL is
"file:///path".

CATEGORY
(Optional) Specifies one or more machining modes in which the event
is relevant. If this keyword is not specified, the event is relevant in all
machining modes. The possible values are the following:
• Mill

• Drill

• Lathe

• WEDM

10
Post Building Techniques – Student Guide 10-7
User defined events and user defined cycles

PARAM <param_name>
Specifies an event parameter with the name specified after the PARAM
keyword.
TYPE
Specifies the parameter type. The possible values are:
i An integer with a standard default value of 0.
d A real number with a standard default value of 0.0
s A string with a standard default value of an empty
string.
o An option list. The first value you specify becomes
the default in the list.
b A Boolean with a standard default value of FALSE.
p A point. NX does not apply a default value.
v A vector. NX does not apply a default value.
g A group of parameters. NX does not apply a
default value.
l A graphic to illustrate the event. NX does not
apply a default value. The value is a lower case L.
DEFVAL <default value>
(Optional) Specifies the default value or string for a parameter. If
this keyowrd is not specified, NX applies the standard default for the
parameter type. For example, if the variable is an integer, it uses
the default integer value.
TOGGLE
(Optional) Specifies that the parameter is optional. The keyword
TOGGLEmust be followed by On or Off to set the default condition. If the
TOGGLEkeyword is not specified, the parameter is mandatory.
OPTIONS
Available only when the parameter TYPE is o. Mandatory for TYPE o.
Specifies a list of options for the parameter. The format is text strings
separated by commas.
UI_LABEL param_ui_name
(Optional) Specifies the parameter name that is displayed in the
NX dialog box. If <param_ui_name> is not specified, NX inserts a
10 default name.

10-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

Enabling the UDE Editor


You must enable the UDE editor to open the User Defined Event dialog box in
Post Builder. You can enable the editor in one of these ways:
• In the NX/Post Builder dialog box, choose Options®Enable UDE
Editor®Yes to enable the editor for one-time use. You must do this before
you open a postprocessor for editing.

• In the Create New Post Processor dialog box, select Enable UDE Editor
to enable the UDE editor whenever the post is opened for edit.

10
Post Building Techniques – Student Guide 10-9
User defined events and user defined cycles

Create a UDE or UDC in Post Builder


The procedures for creating UDEs and UDCs are very similar. The procedure
for a new UDE is illustrated in this example.
1. In Post Builder, on the Program & Tool Path tab, click the Program tab.

2. Under Tool Path, select one of the following pages:


• Machine Control for a new UDE.

• Canned Cycles for a new UDC.

3. Right-click in the background of the page and choose the applicable


command.
The command on the Machine Control page is Create New Machine
Control Event.

4. In the Create Machine Control Event dialog box specify the required
event parameters and any optional parameters that you want to include.

5. Click OK.

6. (Optional) In the User Defined Event dialog box, drag parameter type
buttons, one at a time, to your event dialog box.
For each parameter that you drag, a dialog box lets you enter information
for the parameter type that you selected.

10
10-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

Create an event handler


This example shows how to create a Tcl procedure to set variables, output
NC code, or perform whatever programming task is needed to code output for
a user-defined event.
1. In Post Builder, on the Program & Tool Path tab, on the Program tab,
on the Machine Control page, click a user-defined event marker to edit
the block.

2. (Optional) If you want to add one or more standard words to the output,
do the following:
a. Select a word from the list.

b. Drag Add Word to the window

c. Right click the word address and choose Change Element→User


Defined Expression.

d. Enter the name of a user expression to control the NC output after


the address.

If the word format you require differs from the default, you must also
edit the word format.

3. From the list of available words, choose Command®Custom Command.

4. Drag Add Word to the window 10


Post Building Techniques – Student Guide 10-11
User defined events and user defined cycles

5. In the Custom Command dialog box, in the title box enter a title for
you event handler procedure, and in the Tcl code area add the code to
do the task that you require.

6. Click OK to return to the dialog box for the event block.


You can modify the event handler in one of these ways:

• Return to the event dialog box. Right-click the custom command word
and choose Edit.

• On the Custom Command tab, select the handler from the list and
edit the code in the window .

7. Click OK to return to the Post Builder dialog box.

10
10-12 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

View event handler Tcl code


You can view the Tcl code for a user defined event in a read-only mode, and
compare it to the code that was read from your disk at the beginning of your
current session.
1. On the Output Settings tab, on the Post Files Preview tab, click the
Event Handlers tab.
Your user-defined events appear under the Machine Control node, and
your user-defined cycles appear under the Canned Cycles node.

2. Select the node that corresponds to an event to view the Tcl code.

The upper window shows the current code, and the lower window
shows the code that was on your disk at the beginning of your current
session.

10
Post Building Techniques – Student Guide 10-13
User defined events and user defined cycles

View an event in the .cdl file


You can view the code that defines a user defined event in a .cdl file, and
compare it to the code that was read from your disk at the beginning of your
current session.
1. On the Output Settings tab, on the Post Files Preview tab, click the User
Define Events tab.
Your user-defined events appear under the Non-System Machine Control
Events node, and your user-defined cycles appear under the Non-System
Cycles node.

2. Select the node that corresponds to an event or cycle to view the definition.

The upper window shows the current code, and the lower window
shows the code that was on your disk at the beginning of your current
session.

10
10-14 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

Add user defined events to the NX Manufacturing environment


You must configure a .cdl that contains your user-defined events to be read
in an NX Manufacturing environment definition file so that your events are
visible in NX.
This example shows how to create a custom user defined event (UDE) file
that contains the following:
• A bitmap graphic to illustrate the custom event.

• A link to an HTML file to support your custom event. This file provides
online Help.

• Grouped parameters.

1. Create a bitmap graphic, name.bmp, to illustrate your custom event


and place it in the folder pointed to by the environment variable
UGII_BITMAP_PATH.

2. Create a custom UDE file, name.cdl, to define your custom events


and place it in the folder pointed to by the environment variable
UGII_CAM_USER_DEF_EVENT_DIR.

To create the file, edit the output .cdl file from Post Builder so that
it contains only your custom user-defined events

When you save a post in Post Builder, the associated .cdl file contains all
of the user-defined events that are available in your post, including the
events provided in the standard ude.cdl file.
#example .cdl file for UDEs
MACHINE FANUC
EVENT test_event
{
UI_LABEL "Test Event"
PARAM command_status
{
TYPE o
DEFVAL "Active"
OPTIONS "Active","Inactive","User Defined"
UI_LABEL "Status"
}
PARAM my_picture
{
TYPE l
DEFVAL "my.bmp"
}
}

3. Locate the default user defined event file. 10


Post Building Techniques – Student Guide 10-15
User defined events and user defined cycles

The default file is ${UGII_CAM_USER_DEF_EVENT_DIR}ude.cdl. The


keyword USER_DEFINED_EVENTS in a manufacturing configuration file, for
example, ${UGII_CAM_CONFIG_DIR}lathe.dat, determines the default
.cdl file and the corresponding Tcl code file to be used for user-defined
events.

4. In the .cdl file, in the next non-comment line after the MACHINE keyword,
enter one or more statements to include other files.
The format to include a file is:
INCLUDE {file specification}

For example:
INCLUDE {$UGII_CAM_USER_DEF_EVENT_DIR/Siemens_Cycles.cdl}

If you use a library machine tool, be aware that the definition file
for the machine’s default postprocessor also contains a pointer to a
user-defined event file. The code that points to the file is, by default,
the following:
INCLUDE {$UGII_CAM_USER_DEF_EVENT_DIR/ude.cdl}

You must edit any files with conflicting pointers to remove the
conflicts.

This method of implementing your events has the following advantages:


• It minimizes the effort required when you configure a new NX release.

• It makes it much simpler to manage potential conflicts due to the


pointer in library machine tools.

If NX is already running when you add a custom user-defined event file,


you must reread the manufacturing environment to which you added
the events.

5. (Optional) Create an online Help file, name.html, to support your custom


event and place it in the folder pointed to by the environment variable
UGII_CAM_USER_DEF_EVENT_DIR.

10
10-16 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

6. (Optional) Edit your name.cdl file to include a help statement.


MACHINE FANUC
EVENT test_event
{
UI_LABEL "Test Event"
UI_HELP "More about my test event"
"file:///D:/customization/resource/user_def_event/my_help.htm"
PARAM command_status
{
TYPE o
DEFVAL "Active"
OPTIONS "Active","Inactive","User Defined"
UI_LABEL "Status"
}
PARAM my_picture
{
TYPE l
DEFVAL "my.bmp"
}
}

10
Post Building Techniques – Student Guide 10-17
User defined events and user defined cycles

UDE dialog box graphic requirements


You can include a graphic in the dialog box that appears in NX when a user
adds your event to illustrate the meaning of parameters in the event.
• The graphic must be a BMP file.

• The recommended width is 230 pixels.

• The default folder in which to place the graphics is UGII_BITMAP_PATH.


If you want to place the graphic in a different folder, you must supply the
path. To avoid parser errors, do not include the backslash \ character
in your path name.

The following is a code example to include a bitmap in the ude_xxx.cdl file,


where xxx stands for your custom name.
PARAM illustration
{
TYPE l
DEFVAL "xxx.bmp"
}

10
10-18 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
User defined events and user defined cycles

Activities: User defined events and user defined cycles


In the User defined events and user defined cycles section, do the following
activities:
• Create user defined events

• Modify the coolant UDE to support a high flow rate

10
Post Building Techniques – Student Guide 10-19
User defined events and user defined cycles

Summary: User-defined events and user-defined cycles


User Defined Events provide a mechanism for allowing machine control
events to be defined by the user. Machine control events are used to convey
information concerning the physical state of the machine tool, such as spindle
speed, coolant status, and so on, to the post processor. UDEs are:
• Specified at the start or end of a tool path or any CAM parent object.

• Defined in the ude.cdl file that is referenced by the configuration file.

• Used to call a Tcl routine in your postprocessor that outputs the required
code.

User-defined cycles provide additional control over drilling cycles when you
use them in the hole-making application. They are provided for controls
that support additional parameters to accommodate add-on features, such
as the Siemens 840D.

10
10-20 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
11
Lesson

11 Virtual NC controller

Purpose
In this lesson, you will learn how to create a Virtual NC controller, used by the
Integrated Simulation and Verification application for tool path simulation.

Objective
After you complete this lesson, you will be able to:
• Create a Virtual NC controller.

Post Building Techniques – Student Guide 11-1


Virtual NC controller

11
Integrated simulation and verification overview
The Integrated Simulation and Verification module, or ISV, allows you to
simulate a machine tool with an actual piece part, giving you an overview
of the entire machining process. The simulation process animates the
machine tool motions, taking into account controller functions and cutting
tool configurations.
ISV features collision checking which allows collision detection between
machine components, fixtures, tools, parts and the in-process work piece. The
machine travel limits are also verified. You may also view machine controller
functions including macros, subroutine calls, cycles and function M, G and H
commands.
ISV can improve the quality of machining processes by allowing the
comparison of the designed part to the part which is being manufactured.
ISV consists of the following components:
• Visualize

• Simulation

• Machine Tool Builder

• Controller definitions: Common Simulation (CSE) or Machine Tool Driver


(MTD)

• Setup Configurator

11-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Virtual NC controller

11
Machine Tool Driver
• Generates motion control program and emulates the CNC controller
o Accurate path based on machine tool configuration

o Handles specific machine tool features including macros, cycles and


subroutines

o Can be customized using Tcl scripting language

o Text and graphics feedback initiated by Events

The Machine Tool Driver (MTD), also referred to as the Virtual NC controller,
creates the CNC program that emulates the CNC controller. This is a
programmable interface that instructs the machine tool model on actual
movements and how those movements are displayed. Any motion and
feedback displayed during machine tool simulation is controlled by the
dedicated MTD.
For comparison purposes, the MTD is analogous to the machine tool simulator
as the CNC controller is analogous to the machine tool that it controls. For
each machine tool in the machine tool library, there is a MTD driver available.
For creating an MTD for a new machine tool, you can modify a generic driver
to work with that machine or use the Post Builder to generate the Virtual NC
controller (MTD and Virtual NC controller refer to the same object). MTDs
are written in the Tcl scripting language but may also be developed in higher

Post Building Techniques – Student Guide 11-3


Virtual NC controller

11
level languages such as C++. MTDs can emulate special cycles, User Defined
Events (UDE’s), macros and other CNC controller dependent functions that
the Manufacturing application does not support.

11-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Virtual NC controller

11
VNC work flow
This describes the process for creating a virtual NC controller (VNC) using
NX Modeling, Manufacturing, and Post Builder. This description assumes
that you already have a suitable Post Builder postprocessor for your machine
tool and controller combination.
1. Create a solid assembly model of your NC machine.
• We recommend that you create a separate component part for each
machine part that moves independently, such as tables, saddles, slides.
Model another component for the fixed machine base.

• You need enough accuracy in the shapes to detect collisions between


moving machine parts and your work piece or fixtures.

• You can model a single solid body to represent major subassemblies


that move together as a unit.

• You can omit all details that do not affect collision detection, such as
interior detail of machine components, exterior fittings outside the
working envelope, fasteners, and so on.

• You can refer to the example assemblies in your


...\mach\resource\library\machine\installed_machines for
examples of the type of model that is recommended.

2. Create a part file to hold your kinematic model, and add the machine
assembly to it as a component.

3. Use the Machine Tool Builder application to build the kinematic tree,
starting with the fixed machine base, and adding each moving component
in sequence.
Refer to the examples in your
...\mach\resource\library\machine\installed_machines for examples of
the way the kinematic tree is constructed.

4. Add the machine tool to the machine tool library, by editing the file
...\mach\resource\library\machine\ascii\machine_database.dat.

5. In the library folder in which your machine tool resides, create a .dat file
to describe the location of the postprocessor to use with the VNC.
The data file consists of a single line with three comma-separated
components:
Post description to appear in NX,path_to_post.tcl,path to post.def

Examples in NX include a line that begins with CSE. Omit this line —
you cannot create a CSE driver with the tools described in this procedure.

Post Building Techniques – Student Guide 11-5


Virtual NC controller

11
6. In Post Builder, open the postprocessor and define the VNC characteristics.
Keep the characteristic of the machine consistent with your kinematic
model. Input the travel type and limits for each axis, and identify the
machine zero reference as the first non-rotating component you come to
by traversing up the kinematic tree from the machined part.

7. (Optional) Use Post Builder to add the postprocessor to your


template_post.dat file.

8. In NX, do these steps:


a. Set the load options to properly open your machining assembly and
your kinematic model.

b. Open the part file that contans your NC setup.

c. In the Operation Navigator, change to the Machine Tool view and


double-click the machine node to replace the machine.
When you have an active machine, the list of postprocessors shows
only the description that you included in your data file for the machine.

d. Simulate the tool path for the entire program, or for individual
operations.

11-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Virtual NC controller

11
Activity: Use Post Builder to create a VNC
In the Virtual NC Controller section, do the following activity:
• Use Post Builder to create a VNC

Post Building Techniques – Student Guide 11-7


Virtual NC controller

11
Axes, junctions, and zero reference
Defining axes in machine tool builder
When you define an axis in Machine Tool Builder, think of the motions as tool
motion relative to a stationary part. If it is the table that moves, you should
reverse the direction.

Defining junctions
In Machine Tool Builder, a junction is a coordinate system that is used:
• To guide and constrain the movement of an axis, for example, the junction
for a rotary axis.

• As a reference for other junctions, for example, the MACHINE_ZERO


junction.

• To position or mate something, for example the part mount and tool
mount junctions.

Components that move linearly should reference the MACHINE_ZERO


junction. The junction should be aligned with the directions and orientation
of the NC axes of the machine. When you create this junction on the machine
base component, remember to classify it as Machine Zero.
Rotating components require a junction that is defined in the component to
which they are attached. These junctions do not require a classification.

11-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Virtual NC controller

11
Part mounting junction
When you define the junction to mount the part, think of it as a coordinate
system to which you will position and align the part. It is helpful to design
a corresponding coordinate system and part mount junction in the CAM
setup part. Part mounting components need not contain any geometry in the
kinematic model. You specify the geometry or the part mount junction when
they add the machine tool to a manufacturing setup.
Name Classification Junction
– SETUP _SETUP_ELEMENT PART_MOUNT_JCT
PART _PART, _SETUP_ELEMENT
BLANK _WORKPIECE,
_SETUP_ELEMENT
FIXTURE _SETUP_ELEMENT

Tool mounting junction


When you specify the spindle, remember to classify the spindle as _DEVICE
and its junction as Tool Mount. The CSYS for the tool mounting junction
should have the X-axis pointing in the direction in which you insert the tool
holder into the spindle.
By default, the initial location of the spindle in the machine tool model is used
as the home position to which the machine moves with the G28 command, the
tool change position.

Post Building Techniques – Student Guide 11-9


Virtual NC controller

11
Program zero reference
In Post Builder, you are asked to specify the program zero reference. The
name that you enter in the Program Zero Reference box should be that of
the first non-rotating component that you come to when you traverse up the
kinematic tree from the position of the part.
In the graphic, the part is below the C_SLIDE, a rotating component. The
C_SLIDE is below the B_SLIDE, another rotating component. The first
non-rotating component above the part is the X_SLIDE, so the X_SLIDE is
the program zero reference.

11-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Virtual NC controller

11
Summary: Virtual NC Controller
The Integrated Simulation and Verification module (IS&V) allows you to
simulate a machine tool with an actual piece part, giving you an overview
of the entire machining process. The simulation process animates the exact
machine tool motions, taking into account controller functions and cutting
tool configurations.
In this lesson you:
• Reviewed the components that comprise the Integrated Simulation and
Verification module.

• Used the Post Builder to generate a Virtual NC Controller used in


machine tool simulation.

Post Building Techniques – Student Guide 11-11


11
Lesson

12 Postprocessing with a Siemens


12
controller

Purpose
This lesson describes the procedures required to build postprocessors through
the use of Siemens controller.

Objective
Upon completion of this lesson, you will be able to:
• See the additional information you can get from a Siemens controller post.

Post Building Techniques – Student Guide 12-1


Postprocessing with a Siemens controller

Sinumerik template posts


The following template posts support Sinumerik controllers for mills:
• Sinumerik_802D_3axis
12
• Sinumerik_828D

• Sinumerik_840D

• Sinumerik_840D_millturn

The Sinumerik_840D_lathe template post supports lathes:

Where do I find it?


Post Builder template posts
Application Post Builder
Menu File®New
Location in dialog Controller group®Library list
box

12-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Postprocessing with a Siemens controller

Events and cycles for Sinumerik controllers in NX


Sinumerik 840D Sets default settings including tolerance, high speed
machining parameters, five axis orientation parameters,
and whether the feed rate is defined in a variable.
12
You can add the Sinumerik 840D start event for:
• A single milling operation

• The lowest level program group in the Program view


of the Operation Navigator.

The Compressor option works only with linear motion. If


the Compressor option is set to On, the post will disable
circular output, and output only linear motion.
If you choose Swiveling in the Transformation option
of the Sinumerik_840D user-defined event, CYCLE800
is output and transformation is turned off (TRAFOFF),
otherwise TRANS/AROT is output for coordinate rotation.
You can set the number of significant digits for the output
format, and the appropriate rounding resolutions, with
the custom commands PB_CMD_reset_output_digits and
PB_CMD_set_resolution.
DNC Header Makes the NC output file accessible to the Siemens
Motion Control Information System (MCIS) by appending
the following comments and values to the file before the %
(start of tape) symbol:
;HEADER-START
;NODENAME=$mom_dnc_machine_name
;NCDATANAME=$mom_dnc_program_name
;NCDATATYPE=$mom_dnc_data_type
;VERSION=$mom_dnc_version_number
;RELEASEID=$mom_dnc_release_number
;DEVELNAME=$mom_dnc_user_name
;HEADER-END
;NC-START
%

Add the user-defined event to the top working program


group under NC_PROGRAM in your milling program.

Post Building Techniques – Student Guide 12-3


Postprocessing with a Siemens controller

Sinumerik Lets you call external subroutines. Used by


Program Control MOM_program_control, PB_CMD_MOM_program_control,
PB_CMD_start_of_extcall_operation,
PB_CMD_end_of_extcall_operation,
12 PB_CMD_end_of_extcall_program, and other procedures.

Add the event to a program group for the Sinumerik_840D


and Sinumerik_828D template posts. Do not add it to
operations.

Where do I find it?


Application Manufacturing
Menu Insert®Operation
Location in dialog Operation dialog box®Machine Control group®Edit
box
(Start of Path Events)

12-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Postprocessing with a Siemens controller

Procedures and settings


PB_CMD_set_Sinumerik_default_setting
Set the post default settings (mills only) according to the Sinumerik
version. If the sinumerik_version is not set, the procedure returns without 12
making any settings.
Interprets the On and Off parameters from the event dialog box and the
controller version to sets the appropriate values for variables.
PB_CMD_set_Sinumerik_V7_default_setting
Set the post default settings (802D_3axis) for Sinumerik version 7.
PB_CMD_set_Sinumerik_Version
Sets the Sinumerik version. The default is value is V7.
Sinumerik version 6 and later support CYCLE832 high speed machining
G code output.

Post Building Techniques – Student Guide 12-5


Postprocessing with a Siemens controller

Activity: Postprocess with a Siemens controller


In the Postprocess with a Siemens controller section, do the following activity:
• Postprocess with a Siemens controller
12

12-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Postprocessing with a Siemens controller

Summary Siemens controller support


The Siemens controller templates give you the necessary control and
flexibility to program your Siemens controllers.
In this lesson you: 12
• Built and examined a standard post for a Siemens 840D controller.

Post Building Techniques – Student Guide 12-7


12
Lesson

13 Create a macro with Post Builder

Purpose 13
This lesson describes the procedures required to build a macro with Post
Builder.

Objective
After you complete this lesson, you will be able to:
• Build a macro with Post Builder.

Post Building Techniques – Student Guide 13-1


Create a macro with Post Builder

Macro tab
Use this tab to create, edit, or remove block templates for making calls to
macro, cycle, or functions in the NC program.
The output codes are in the form of cycle or macro calls, such as CYCLE81(...)
for the Sinumerik 840D controller or CYCLE DEF 204 A200=... for the
Heidenhain iTNC530 controller, or other similar high level function calls.

Adding macros
13 Post Builder provides constructs for well-known hole-making cycles attached
to appropriate events.
Add you own macros when you wish to extend the post to output macro calls
for other calls that your controller accepts.

13-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Create a macro with Post Builder

13

Sets characters to follow macro


parameter words, for example, set
List of macros in the current post.
to none, you might see X1.234 as
You can create a new macro, or cut,
an output parameter. With Link
paste, or rename macros.
Character set to Equal Sign, the
output for the same value is X=1.234.
Sets the format of the parameter
list. You can change the separator
Preview of the output macro call. and the start and end characters. The
defaults are a comma separator. The
list starts with ( and ends with ).
Textual or graphical information Right-click to set the word
about the cycles of a controller may character for each parameter in the
be provided by the manufacturer, for macro call. Right-click the outer edges
example, Siemens. Click to display of the box to cut and paste parameters.
the info page for the macro or cycle, The New right-click option inserts a
if available. row after the selected parameter.
Sets the expression for the value
Sets the output word for the macro of parameters. Choose a common
or cycle call. expression or edit the expression as
required.
Sets the format for the parameter output as a numeric format or text string.

Post Building Techniques – Student Guide 13-3


Create a macro with Post Builder

Notes
The additional output attributes are not applicable to the Siemens Sinumerik
840D. The options do not appear on the macro constructor for the Sinumerik
family of posts.
You can define as many parameters as your controller requires.
If a macro parameter is not to be output, its name is used only in Post Builder
to represent an available argument.
13 You can set the expression for each parameter using constants, global MOM
variables, or other Tcl variables. The variables you use should represent
data of the same type as specified by the Data Type option, the same number
format, or text.
Your macros for the current post appear in the list of available blocks on
the Program tab.
You can create new macros by choosing Custom Macro from the list of
available blocks. The tree list does not appear; otherwise, the interface is
the same.
On the Program tab, when you attach your macro to an event, you can
suppress the sequence number.

13-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Create a macro with Post Builder

Activity: Create a macro with Post Builder


In the Create a macro with Post Builder section, do the following activity:
• Create a Macro with Post Builder

13

Post Building Techniques – Student Guide 13-5


Create a macro with Post Builder

Summary: Create a macro with Post Builder


Creating a macro in Post Builder gives you the ability to machine a part
to special needs.
In this lesson you:
• Created a macro and used that macro to machine a portion of a part.

13

13-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Lesson

14 Project activities

Purpose
Do the project activities as time permits for additional practice in Post
Building skills.

Available activities
14
• Collecting data for postprocessor creation

• Building a postprocessor with NX Post

• NX Post: Program and Tool Path functions

• NX Post: N/C Data Definition functions

• Advanced Customization

Post Building Techniques – Student Guide 14-1


14
Appendix

A A guide to best practices of


building a postprocessor

Overview
As you gain experience with the various Post components, you will find
yourself experimenting with numerous methods and techniques as you go
through the post development cycle. Eventually, you will settle on methods
that you have become familiar and comfortable with.
The following suggestions and procedures will aid you in the creation of
postprocessors.
A

Post Building Techniques – Student Guide A-1


A guide to best practices of building a postprocessor

A-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
A guide to best practices of building a postprocessor

• When adding multiple custom commands, add and test each custom
command individually. This will make the process of debugging easier
and less confusing when you encounter Tcl syntax or Post errors.

• Use the Review Tool always when debugging a post processor. Although
the Review Tool increases the time required for processing, it is an
invaluable aid in the debugging process. The Review Tool may also be
used to review MOM Events, MOM variables per Event, find missing
procedures and find MOM variable names.

• Always make a copy of the main CAM mach directory for testing and
debugging purposes. The idea behind this concept is that you can
experiment with various ideas and techniques without the worry of
corrupting any system files that would normally be used by NX Post or
the Post Builder.

• If using the Post Builder to create a post and you find that you may need
to edit the Event Handler or Definition file, make sure that you perform
all edits and modifications that you can do within the Post Builder. Once
you "manually" edit the files, which Post Builder creates, the link between
those files and Post Builder are lost. This prevents you from using the A
Post Builder on that particular post again.

• UDE defined variables can be retrieved in MOM_start_of_program or


MOM_start_of_path by use of Tcl command, uplevel.

• Manufacturing attributes cannot be retrieved in MOM_start_of_program.

• Expression variables can be retrieved at any time.

• Additional Tcl or Tk programs can be sourced and run from within the
machine tool Tcl file.

• To remove a file in MOM use MOM_remove_file.

Post Building Techniques – Student Guide A-3


A
Appendix

B Appendix: Checklist of
information

This portion of the Appendix contains a checklist that can be used to record
information needed to create a postprocessor.
The checklist which follows has been partially completed to save time. You
will notice that a checkmark precedes some of the boxes. This indicates that
the particular option does exist.
Checklist of information used to create a postprocessor
Machine Tool Type
Description of machine: UGS Supermill
3-axis mill
4-axis mill
5-axis mill
2-axis lathe B
4-axis lathe
Mill / turn center
Wire EDM
Other type

If 4-axis mill 4th axis is;


Positioning
Contouring

Maximum Axis Travels:


X-axis: 39.37” Y-axis: 39.37” Z-axis 19.685”
Other:___________________________________________
Word Formats
XYZ:___________ IJK:____________ UVW:___________

R: ____________F: _____________S: ____________N: _____5_______


Decimal Point :

Post Building Techniques – Student Guide B-1


Appendix: Checklist of information

Yes
No

Drop leading zeros:


Yes
No

Drop trailing zeros:


Yes
No

Minimum resolution for output: .0001 inches


Maximum allowable Sequence Number: 99999
Miscellaneous Defaults
Inch

Metric

Absolute

Incremental

Rapid Position Feed Rate Value: 1575"/min X,Y; 1575"/min Z


B Circular Interpolation Parameters
Quadrant Limited

Full Circle

Maximum radius for circular interpolation: 999.9999 inches


Minimum radius for circular interpolation: .010 inches
Arc center offset designation:
I,J,K is a signed vector, arc start to circle center Inch

I,J,K is a signed vector, circle center to arc start

I,J,K is an unsigned vector, arc start to circle center.

I,J,K is absolute circle center co-ordinates

radius value

Other

Preparatory Functions (G Functions)

B-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Checklist of information

G00 Positioning
G01 Linear interpolation
G02 Circular/Helical Interpolation CW
G03 Circular/Helical Interpolation CCW
G02.2, G03.2Involute Interpolation
G04 Dwell
G05 High Speed Machining
G07.1 Cylindrical Interpolation
G12.1 Polar coordinate interpolation
G13.1 Polar coordinate interpolation cancel
G15 Polar coordinate command cancel
G16 Polar coordinate command
G17 XY plane selection
G18 XZ plane selection
G19 YZ plane selection
G20 XY Inch input
G21XY Metric input
G25 Spindle speed fluctuation detection off B
G26 Spindle speed fluctuation detection on
G27 Reference position return check
G28 Return to reference position
G29 Return from reference position
G33 Thread cutting
G40 Cutter compensation cancel
G41 Cutter compensation left
G42 Cutter compensation right
G43 Tool length compensation +
G44 Tool length compensation -
G49 Tool length compensation cancel
G50 Scaling cancel
G51 Scaling
G54-G59 Workpiece coordinate selection

Post Building Techniques – Student Guide B-3


Appendix: Checklist of information

G65 Macro call


G66 Macro modal call
G67 Macro modal call cancel
G80 Canned cycle cancel
G81 Canned drilling cycle
G82 Canned counterboring cycle
G83 Canned peck drilling cycle
G84 Canned tapping cycle
G84.1 Rigid tapping cycle
G85 Canned boring cycle
G87 Canned back boring cycle
G90 Absolute mode
G91 Incremental mode
G92 Setting for work coordinate system
G94Feed per minute
G95 Feed per revolution
G96Constant surface speed
B G97Constant surface speed cancel
G98 Return to initial point in canned cycle
G99Return to R point in canned cycle
Auxiliary Functions (M Functions)
Number of M codes per block:_____3
M00 Program stop
M01 Optional stop
M02 End of program
M03 Spindle on CLW
M04 Spindle on CCLW
M05 Spindle off
M06 Tool change
M07 Coolant on flood
M08 Coolant on, mist
M09 Coolant off

B-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Checklist of information

M30 Rewind
M51Thru Spindle Coolant System
M100 Low Pressure Thru Spindle Coolant
M101 Medium Pressure Thru Spindle Coolant
M103 High Pressure Thru Spindle Coolant
Character for Rewind Stop Code: "#"
Tool / Head parameters
Maximum number of tools: 120
Is pre selection of tool allowed Yes
Tool diameter compensation code:________D
Minimum compensation code:_______0
Maximum compensation code:____999
Tool length compensation code:___________H
Minimum compensation code:_______0
Maximum compensation code:____999
Should adjust code be held for "Z" motion?
Yes B
No
Spindle parameters
Maximum spindle RPM: 24000
Minimum spindle RPM: 15
Is spindle off code required to change spindle direction
Yes
No
Feed rate parameters
Maximum feed rate: 1575 ipm
Minimum feed rate: .0010 ipm

Post Building Techniques – Student Guide B-5


Appendix: Checklist of information

Checklist of information needed for postprocessor development


Machine Tool Type
Description of machine: UGS Supermill
3-axis mill
4-axis mill
5-axis mill
2-axis lathe
4-axis lathe
Mill / turn center
Wire EDM
Other type

If 4-axis mill 4th axis is;


Positioning
Contouring

Maximum Axis Travels:


X-axis: _________ Y-axis: __________ Z-axis ____________
Other:___________________________________________
Word Formats:
XYZ:___________ IJK:____________ UVW:___________
B
R: ____________F: _____________S: ____________ N: _____5_______
Decimal Point :
Yes
No

Drop leading zeros:


Yes
No

Drop trailing zeros:


Yes
No

Minimum resolution for output: ____________ inches


Maximum allowable Sequence Number: ____________
Miscellaneous Defaults
Inch

B-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Checklist of information

Metric

Absolute

Incremental

Rapid Position Feed Rate Value: _________ X,Y; ___________ Z


Circular Interpolation Parameters
Quadrant Limited

Full Circle

Maximum radius for circular interpolation: _________inches


Minimum radius for circular interpolation: _________inches
Arc center offset designation:
I,J,K is a signed vector, arc start to circle center Inch

I,J,K is a signed vector, circle center to arc start

I,J,K is an unsigned vector, arc start to circle center.

I,J,K is absolute circle center co-ordinates

radius value
B
Other

Preparatory Functions (G Functions)


G00 Positioning
G01 Linear interpolation
G02 Circular/Helical Interpolation CW
G03 Circular/Helical Interpolation CCW
G02.2, G03.2Involute Interpolation
G04 Dwell
G05 High Speed Machining
G07.1 Cylindrical Interpolation
G12.1 Polar coordinate interpolation
G13.1 Polar coordinate interpolation cancel
G15 Polar coordinate command cancel
G16 Polar coordinate command

Post Building Techniques – Student Guide B-7


Appendix: Checklist of information

G17 XY plane selection


G18 XZ plane selection
G19 YZ plane selection
G20 XY Inch input
G21XY Metric input
G25 Spindle speed fluctuation detection off
G26 Spindle speed fluctuation detection on
G27 Reference position return check
G28 Return to reference position
G29 Return from reference position
G33 Thread cutting
G40 Cutter compensation cancel
G41 Cutter compensation left
G42 Cutter compensation right
G43 Tool length compensation +
G44 Tool length compensation -
G49 Tool length compensation cancel
B G50 Scaling cancel
G51 Scaling
G54-G59 Workpiece coordinate selection
G65 Macro call
G66 Macro modal call
G67 Macro modal call cancel
G80 Canned cycle cancel
G81 Canned drilling cycle
G82 Canned counterboring cycle
G83 Canned peck drilling cycle
G84 Canned tapping cycle
G84.1 Rigid tapping cycle
G85 Canned boring cycle
G87 Canned back boring cycle
G90 Absolute mode

B-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Checklist of information

G91 Incremental mode


G92 Setting for work coordinate system
G94Feed per minute
G95Feed per revolution
G96Constant surface speed
G97Constant surface speed cancel
G98 Return to initial point in canned cycle
G99Return to R point in canned cycle
Auxiliary Functions (M Functions)
Number of M codes per block:______
M00 Program stop
M01 Optional stop
M02 End of program
M03 Spindle on CLW
M04 Spindle on CCLW
M05 Spindle off
M06 Tool change
M07 Coolant on flood B
M08 Coolant on, mist
M09 Coolant off
M30 Rewind
M5 1Thru Spindle Coolant System
M100 Low Pressure Thru Spindle Coolant
M101 Medium Pressure Thru Spindle Coolant
M103 High Pressure Thru Spindle Coolant
Character for Rewind Stop Code: _________
Tool / Head parameters
Maximum number of tools: _________
Is pre selection of tool allowed _________
Tool diameter compensation code:________
Minimum compensation code:_______
Maximum compensation code:__________

Post Building Techniques – Student Guide B-9


Appendix: Checklist of information

Tool length compensation code:___________


Minimum compensation code:_______________
Maximum compensation code:____________
Should adjust code be held for "Z" motion?
Yes
No
Spindle parameters
Maximum spindle RPM: _________
Minimum spindle RPM: _________
Is spindle off code required to change spindle direction
Yes
No
Feed rate parameters
Maximum feed rate: _________ ipm
Minimum feed rate: ________ ipm

B-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix

C Appendix: Supermill technical


document

This appendix contains the technical specification for the UGS Supermill
Machining Center. These specifications will be used to create the
postprocessor for the project exercises.
The UGS Supermill is a high performance, high speed 3-axis vertical
machining center with an optional indexable head. A 5-axis version for
complex molds and impellers is also available.
The design of the Supermill incorporates a rigid frame and self cooling high
speed spindle that aids in high speed machining applications. The Supermill’s
modular concept enables its use in numerous applications.

Post Building Techniques – Student Guide C-1


Appendix: Supermill technical document

UGS Supermill

Technical Description
Machine Structure
The Supermill is a standard "bed" type machine, which allows for machine
rigidity and stability. The design of the Supermill allows for excellent
visibility of the actual working area. The bed, table, vertical walls and guides
of the X-axis are comprised of cast iron. The Y and Z guides are manufactured
from precision ground steel.
Machine bed and X, Y, Z axis slides
The machine bed is built from fixed box-shaped structures designed with
transverse baffles for rigidity. This adds to the general stability of the
machine. The machine guideways incorporate rolling bearing mechanisms.
Axis movements are accomplished with recirculating ball screws, driven by
brushless dc motors. The X and Y-axis have direct motor screw couplings;
the Z-axis is belt driven. Glass scales are used for accurate positioning. All
transducers are metal clad and are protected against dust and coolant. They
are also connected to a filtered compressed air system to further aid in the
reduction of contaminants.
Machine temperature control system
In order to minimize thermal drifts and maintain accuracy when machining
for extended periods, heat exchangers are placed in strategic locations. These
heat exchangers dissipate heat to a continuously circulating liquid controlled
by a standalone refrigeration unit.
Machining work area

C The machining work area, or work piece table, is made of cast iron, for
thermal stability, and is equipped with T-slots for work piece clamping.
Automatic tool changer
The automatic tool changer is a chain operated device that can store up to 180
tools. Tool selection is bi-directional, that is, the chain will move clockwise or
counterclockwise to the next tool selected, which ever direction is shorter. The
tool changer will automatically detect a tool in a pocket and will also monitor
tool life through software incorporated in the CNC.
Lubrication systems
Key components including slides and spindle are constantly lubricated by
means on an automatic lubricating system regulated by a timing mechanism.
These components are monitored by sensors, which will activate alarms when
lubrication is low.
Coolant System

C-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

The coolant system dissipates heat generated by cutting through a mixture


of air and non-toxic vegetable oil. The air/oil mixture is regulated by control
valves and a nozzle system which can be directed to the cutting tool and
or work piece. Coolant on and off is controlled by the use of M functions or
manual intervention by the operator.
Drives and axis motors
All drive motors are AC and are brushless. The electronic interface between
the drives and CNC is digital.
Electrical cabinet
The electrical cabinet is self contained and mounted on the left side of the
machine and is equipped with a forced ventilation cooling system. The
cabinet meets all NEMA regulations. The cabinet is also equipped with
meters to monitor total service hours, total spindle hours, contains internal
service lighting and is provided with a 120V AC outlet.
Safety guards
The machine is completely enclosed by safety guards. Two front side sliding
doors allow for easy loading and unloading of work pieces. The doors are
equipped with electromechanical safety locks. The doors can be opened only
after the machine spindle comes to a complete stop. Inspection cycles, such as
probing can be performed with the doors open. Any operation involving the
rotation of the spindle prevents the doors from being opened.
Chip Removal
The design of the machine allows chips to move towards the front of the
machine into a removable chip container. The chip container can be removed
while the machine is operating.
UGS Supermill Computer Numerical Control
C
Includes the following:
XP Professional operating system
CPU Pentium I 3.500 GHz
19" graphic video terminal
512 MB RAM memory
800 GB hard disk memory
1.44 MB floppy disk drive
Alphanumeric keyboard
Operator remote pushbutton pendent including hand wheel and displays
Ethernet board
Multi-processor CPU architecture
Digital controls for axis drives
Diagnostics and help-on-line.

TECHNICAL DATA Supermill

Post Building Techniques – Student Guide C-3


Appendix: Supermill technical document

Linear axes
Movement
1000 mm (39.37")
X
1000 mm (39.37")
Y
500 mm (19.685")
Z
Positioning accuracy 0.005 mm (.0002")
Max. rapid speed X - Y 40 m/min (1575"/min)
Z 40 m/min (1575"/min)
Number of tool pockets in changer 180 Maximum
Work piece table
1500 x 1500 mm (59" x 59")
Standard table dimensions
Max load on table 2500 Kg. ( 1140 lbs.)
Longitudinal T-slots: number 5
width 18 mm (.708")
Installation requirements
440 V 60 Hz
Power supply
Air supply 20 psi + 10%
Machine weight 12000 kg (5454 lbs.)
Floor space (excluding command panel
3.9 x 3.9 m (12.8 x 12.8 ft)
and spindle cooling device)
Overall height 3.2 m (10.5 ft)
Environmental conditions
from 10 to 40 5C
Temperature
Relative humidity from 10% to 80%

C-4 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Milling options
The following three milling options are available for the Supermill.

3-Axis Milling 24000 RPM


Includes the following:
• High frequency spindle, 220-mm. dia. with air/oil lubricated ceramic ball
bearings and automatic tool clamping/unclamping system.

The tool holder clamping on the spindle consists of a mechanical device with
Belleville washers; a pneumatic piston unclamps the tool holder. The spindle
is housed on the vertical slide (Z-axis).
• Spindle drive.

• Cooling system.

• Air/oil lubrication of ball bearings with recirculating oil.

TECHNICAL DATA 3-axis milling


Max. spindle rotation speed 24000 RPM
Continuous power 2.4 kW
Constant power range 6000 - 24000 RPM
Spindle lubrication air-oil
Tool holder CAT 50
Spindle nose-table max distance 760 mm
Spindle axis machine bed minimum 230 mm.

3-axis milling with indexable head (4th and 5th axis) 30000 RPM
This option allows for tool orientation, which will increase the work area, C
reduce tool lengths and increase cutting speeds with spherical tools.
Includes the following:
• Bi-directional indexable head with integrated spindle, housed on the
vertical slide.

• High frequency spindle, 150 mm. dia. with air/oil lubricated ceramic ball
bearings and automatic tool clamping /unclamping system.

The tool holder clamping on the spindle consists of a mechanical system with
Belleville washers; a pneumatic piston unclamps the tool holder.
• Motor and drive for C-axis movement.

• Hydraulic unit for clamping/unclamping table, B-axis movement and


tool unclamping.

Post Building Techniques – Student Guide C-5


Appendix: Supermill technical document

• Automatic tool center compensation when changing head angle.


Spindle cooling system.
3-Axis milling with indexable
TECHNICAL DATA
head
C-axis movement + 180°, -177°
C-axis pitch 3°
B-axis movement 25°, +25°
B-axis pitch 5°
Max. spindle rotation speed 30.000 RPM
Continuous power 2.7 kW
Constant power range 24000 - 30000 RPM
Spindle lubrication air/oil
Tool holder Cat 50
Spindle nose-table max distance
687 mm.
(spindle in vertical position)
Spindle axis — machine bed min. 280 -380 mm *
distance (*distance differs along with C-axis
(spindle in vertical position) position)

5-Axis Continuous Milling Option 28000 RPM


This option enables continuous orientation of the tool in the space which
allows for undercut machining, surface contouring, convex surface machining
with standard end mills, tool length reduction and increased cutting speeds
with spherical tools.
Includes the following:
• Bi-directional milling with continuous B and C axis movements with
integrated spindle.
C
• High frequency spindle 120 mm. dia. with air/oil lubricated ceramic ball
bearings and automatic tool clamping /unclamping system. The tool
holder clamping on the spindle consists of a mechanical system with
Belleville washers; a pneumatic piston unclamps the tool holder.

• Brushless motor and drives for B and C axis.

• Direct positional transducers.

• Internal calculation of tool motion with reference to the tool center.

• Spindle refrigerated cooling system.

TECHNICAL DATA 5-axis continuous milling


B axis movement +/– 110°
C axis movement +/– 361°

C-6 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

TECHNICAL DATA 5-axis continuous milling


B and C axis max. rotating speed 5000°/min
Max. acceleration 10005/sec²
Max. spindle rotating speed 28000 RPM
Continuous power 5 kW
Constant power range 16000 - 28000 RPM
Tool holder CAT 40
Max. tool dia. in milling 16 mm
Spindle nose table max. distance
562 mm
(spindle in vertical position)
Spindle axis - machine bed min.
distance 245 mm
(spindle in vertical position)

Post Building Techniques – Student Guide C-7


Appendix: Supermill technical document

Tool Length pre-setting options

Manual tool length pre-setting


The manual tool length pre-setting option consists of an analog measuring
device that is positioned and referenced from the work piece table.

Automatic Tool Length pre-setting


This option consists of a device that is fixed to the machine table. It includes
a digital probe for gauging, an air-blow system for probe cleaning, interface
boards, wiring and software to automatically pre-set tool lengths.

Laser probe pre-setting


The laser probe pre-setting option consists of a laser measuring system
that will check the diameter, length and shape of the tools according to
preprogrammed measuring cycles. Included in this option are all connecting
cables, interface boards and measuring software.

C-8 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Chip Conveyor

CC SM2004
The automatic chip conveyor option allows the continuous removal of chips
and is operated directly by the CNC. This option replaces the standard chip
conveyor.

Post Building Techniques – Student Guide C-9


Appendix: Supermill technical document

Dust removal system (vacuum)

VDRS SM2004 graphite dust removal option


The graphite dust removal option consists of an externally supplied suction
unit complete with a container and self-cleaning filter. The filter device
is connected through pipes to a suction manifold mounted along the table
of the machine.
Technical data for the VDRS SM2005 dust removal system
Fan power:5.5 kW
Air volume:1500 cubic ft/ minute
Overall dimensions:1.2 x 1.4 m.
Height:3 m.

C-10 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Measurement options

DPM SM2005 Digital probe measuring system


Included in this option are the following:
• Universal digital inspection probe

• Standard 50 mm. stylus

• Interface board and wiring

• Adapter for digital probe

UGS 2005M Software for fixed probing cycles.


This software allows:
Error calculation with respect to pre-set values
3-D measurements
Recording all data in standard file formats for later analysis

Post Building Techniques – Student Guide C-11


Appendix: Supermill technical document

Specialized application software


Supermill uses the standard MicroSoft Windows XP operating system. This
allows for ease of use with a standard interface and the simple integration
of NX at the shop floor level.

Supermill SHOPS CAM SOFTWARE optional


SHOPS is integrated with the CNC controller which allows the interactive
generation of 3D tool paths. Functions included are:
Import of IGES models.
Roughing and finishing cycles with ball and flat end-mills.
Semi-finishing and finishing cycles for high-speed milling.
High-resolution display of models and stock material.
Options available specifically for the die/mold industry.

Data transfer
High speed data transmissions via ethernet and TCP/IP protocol.

C-12 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Supermill CNC options

Scale factor
Scale factor assigns a different scale to each individual axis. This option is
applicable in the manufacturing of molds, where shrink factors are different
along the various individual axis.

Polynomial interpolation with Nurbs format


Nurbs format allows for better surface finishes when finishing with the high
speed machining option.

21" High resolution video


Upgrade with 21" video terminal instead of 19" video.

Remote push button operator pendant


This option allows the operator to independently move each axis for set-up
purposes as well as to monitor and change various functions.

Post Building Techniques – Student Guide C-13


Appendix: Supermill technical document

Programming functions
The following programming functions are standard with the Supermill 2004
CNC controller.

Preparatory functions (G function)


Up to three multiple G functions can be included in the same block of
information.
The following G functions are recognized by the Supermill:
G00 Rapid Positioning
G01 Linear positioning (interpolation) at programmed feed rate
G02 Circular/Helical interpolation CW
G03 Circular/Helical interpolation CCW
Circular interpolation can be performed in the XY, XZ or YZ plane.
Along with X, Y, Z departures, parallel axis used for interpolation are I, J, and
K. I represents the X axis signed distance from the start point to the center of
the arc; J represents the Y axis signed distance from the start point to the
center of the arc; and K represents the Z axis signed distance from the start
point to the center of the arc. I, J and K are always the incremental distance.
In place of I, J, or K, R with the appropriate radius value can also be used.
When the arc specified is greater than 180 degrees, the radius value R is
specified with a negative value.
G04 Dwell
G05 High speed machining cycle (optional)
G12.1 Polar co-ordinate interpolation mode (optional)
C
G13.1 Polar co-ordinate interpolation mode, cancel (optional)
G17 XY plane selection
G18 XZ plane selection
G19 YZ plane selection
G20 Input in inch
G21 Input in metric
G25 Spindle speed fluctuation detection off
G26 Spindle speed fluctuation detection on
G27 Reference position return check (optional)
G28 Return to reference position
G29 Return from reference position

C-14 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

G40 Cutter compensation cancel


G41 Cutter compensation left
G42 Cutter compensation right
G43 Tool length compensation +
G44 Tool length compensation
G49 Tool length compensation cancel
G50 Scaling cancel (optional)
G51 Scaling (optional)
G54-G59 Workpiece Co-ordinate selection register
G80 Canned cycle cancel
G81 Canned drilling cycle
G82 Canned counter boring cycle
G83 Canned peck drilling cycle
G84 Canned tapping cycle
G84.1 Canned rigid tapping cycle
G85 Canned boring cycle
G87 Canned back boring cycle
G90 Absolute co-ordinate programming
G91 Incremental co-ordinate programming
G92 Set work co-ordinate system
G98 Return to initial point in canned cycle
G99 Return to R point in canned cycle
C
Auxiliary functions (M functions)
Up to three multiple M functions can be included in the same block of
information.
M00 Stop
M01 Optional Stop
M02 End of Program
M03 Spindle On CLW
M04 Spindle On CCLW
M05 Spindle Off
M06 Tool change

Post Building Techniques – Student Guide C-15


Appendix: Supermill technical document

M07 Coolant On, Flood


M08 Coolant On, Mist
M09 Coolant Off
M51 Thru Spindle Coolant System
M100 Low Pressure Thru Spindle
M101 Medium Pressure Thru Spindle
M103 High Pressure Thru Spindle
M30 Rewind

Spindle speed function (S function)


The spindle speed can be controlled by specifying a value following the
address S. Maximum number of digits is five. Spindle speed range is based on
spindle option package. See individual specifications for speed range.

Tool selection function (T function)


Tools can be selected on the machine by specifying a 4-digit numerical value
following the T address code. When a move command and a T code are
specified in the same block, simultaneous execution of the move command
and the tool change occurs. Codes specifying tool offset values are grouped
with H codes for tool length offset and D codes for cutter compensation
offset. Maximum values for H codes and D codes are 999. An M06 command
performs the actual tool change.

Feed functions
The feed function controls the feed rate of the cutting tool.
C The Rapid Traverse feed function moves the tool at a rapid traverse rate
when command to position by G00.
The Cutting feed function moves the tool at a programmed cutting feed rate.
Acceleration and deceleration are automatically applied when the tool starts
and ends its movement.
Cutting feed rate is applied by a number following the F word address.

Word address and decimal point programming


Numerical values can be entered with a decimal point. Decimal points can be
specified for the following addresses:
X, Y, Z, I, J, K, U, V, W, B, C, R and F.
Some G codes allow for decimals (Polar co-ordinate interpolation)
Fixed word lengths are as follows:

C-16 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Inch 3.4 for X, Y, Z, I, J, K, U, V, W, B, C, R


Metric 4.3 for X, Y, Z, I, J, K ,U, V, W, B, C, R
Spindle 5 digits
Feed rate:
Inch 3.4
Metric 4.3

Post Building Techniques – Student Guide C-17


Appendix: Supermill technical document

Milling accessories

Accessories for CAT 50 tool holder


Includes the following:
balanced tool holder enabling the clamping of tools with cylindrical shanks.
extended balanced tool holder, enabling the clamping of tools with extended
length cylindrical shanks.
tool holder for Weldon type tools.
Sets of 7 collets (diam. 4 mm, 6 mm, 8 mm, 10 mm, 12 mm, 16 mm, 20 mm).
Sets of 4 collets (diam. 1 mm, 2 mm, 4 mm, 6 mm).
Spanner wrenches for various collets.
Tool holder support for tool assemblies.

Optional spindles
UGSSM2005/24-24
24 kW- 24000 RPM high frequency spare spindle for 3-axis option.
UGSSM2005/20-30
20 kW - 30000 RPM high frequency spare spindle for indexable head option.
UGSSM2005/6-28
6/7,5 kW - 28.000 RPM high frequency spare spindle for 5-axis option.

C-18 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Appendix: Supermill technical document

Services

Installation
Includes machine installation and acceptance at purchaser’s facilities.
The Supermill requires special foundations per drawing number
SM2005HS-01. These foundations to be built at purchaser’s expense
according to aforementioned drawing specifications.
Installation of the Supermill can be performed 4 weeks after the foundation
has been poured.
Purchaser provides all necessary pneumatic, power and water supplies.

Training
Siemens PLM Software will provide 40 hours of training, at the customer’s
site, on the use and programming of the Siemens PLM Software Supermill
CNC controller.
For custom training courses, please contact UGS.

Shops training
Please check Educational Services schedules for the nearest location and
dates Shops classes. Special classes can be arranged on site.

Post Building Techniques – Student Guide C-19


C
Index

B Post Builder . . . . . . . . . . . . . . . . . . . 1-6


5-axis . . . . . . . . . . . . . . . . . . . . . . 5-2
Best Practices . . . . . . . . . . . . . . . . . A-3
lathe . . . . . . . . . . . . . . . . . . . . . . 6-2
Definition file . . . . . . . . . . . . . . . . A-3
Postprocessing
Overview . . . . . . . . . . . . . . . . . . . A-1
definition of . . . . . . . . . . . . . . . . . 1-2
block component . . . . . . . . . . . . . . 2-26
Postprocessor
editing of . . . . . . . . . . . . . . . . . . 2-26
NX Post Execute . . . . . . . . . . . . . . 1-3
Program and Tool Path tab
C Custom Commands . . . . . . . . . . . 2-21
Custom Commands . . . . . . . . . . . . . 9-3 Word Sequencing . . . . . . . . . . . . 2-21

F S
Files Preview tab . . . . . . . . . . . . . . 2-52 Sequence . . . . . . . . . . . . . . . . . . . . 2-24
Miscellaneous . . . . . . . . . . . . . . . 2-25
I Operation End . . . . . . . . . . . . . . 2-25
Operation Start . . . . . . . . . . . . . 2-24
Integration, Simulation and Verification Program End . . . . . . . . . . . . . . . 2-25
machine tool driver . . . . . . . . . . . 11-3 Program Start . . . . . . . . . . . . . . 2-24
overview . . . . . . . . . . . . . . . . . . . 11-2 Tool Path Events . . . . . . . . . . . . 2-24
Canned Cycle Events . . . . . . 2-25
M Machine Control Events . . . . 2-25
Machine Tool tab Motion Events . . . . . . . . . . . 2-25
Default button . . . . . . . . . . . . . . 2-12
Restore button . . . . . . . . . . . . . . 2-12 T
Manufacturing Output Manager . . . 1-5 Tcl
Mill-turn command
creating using Post Builder . . . . . . 7-2 array get . . . . . . . . . . . . . . . . 8-9
defining heads . . . . . . . . . . . . . . . 7-4 break . . . . . . . . . . . . . . . . . . 8-46
catch . . . . . . . . . . . . . . . . . . 8-23
N close . . . . . . . . . . . . . . . . . . 8-32
N/C Data Definitions tab . . . . . . . . 2-28 continue . . . . . . . . . . . . . . . . 8-47
NX Post exit . . . . . . . . . . . . . . . . . . . 8-48
User Defined Events . . . . . . . . . . 10-4 expr . . . . . . . . . . . . . . . . . . . 8-10
file exists . . . . . . . . . . . . . . . 8-30
for . . . . . . . . . . . . . . . . . . . . 8-44
P
foreach . . . . . . . . . . . . . . . . . 8-45
Parameter Window . . . . . . . . . . . . 2-23 format . . . . . . . . . . . . . 8-16, 8-26

Post Building Techniques – Student Guide Index-1


Index

gets . . . . . . . . . . . . . . . 8-24, 8-32 lines . . . . . . . . . . . . . . . . . . 8-18


global . . . . . . . . . . . . . . . . . . . 8-8 special characters . . . . . . . . . . . . 8-14
if then elseif if . . . . . . . . . . . 8-41 style
incr . . . . . . . . . . . . . . . . . . . 8-44 indentation . . . . . . . . . . 8-8, 8-18
info exists . . . . . . . . . . . . . . 8-12 tests for file permissions . . . . . . . 8-36
open . . . . . . . . . . . . . . . . . . 8-30 variable
options . . . . . . . . . . . . . . . . . . 8-4 arrays . . . . . . . . . . . . . . . . . . 8-9
proc . . . . . . . . . . . . . . . . . . . 8-19 defined . . . . . . . . . . . . . . . . . . 8-6
puts . . . . . . . . . . . . . . . 8-24, 8-32 reference . . . . . . . . . . . . . . . 8-10
read . . . . . . . . . . . . . . . . . . . 8-33 scope . . . . . . . . . . . . . . . . . . . 8-8
return . . . . . . . . . . . . . . . . . 8-22 substitution . . . . . . . . . . . . . 8-10
scan . . . . . . . . . . . . . . . . . . . 8-28 substitution examples . . . . . 8-11
set . . . . . . . . . . . . . . . . . . 8-3, 8-7 valid names . . . . . . . . . . . . . . 8-6
source . . . . . . . . . . . . . . . . . 8-25 values . . . . . . . . . . . . . . . . . . 8-7
split . . . . . . . . . . . . . . . . . . . 8-33 working with . . . . . . . . . . . . 8-10
string . . . . . . . . . . . . . . . . . . 8-37 words . . . . . . . . . . . . . . . . . . . . . 8-13
switch . . . . . . . . . . . . . . . . . 8-43 working with file specifications . . 8-34
unset . . . . . . . . . . . . . . . . . . . 8-7 working with files . . . . . . . . . . . . 8-30
while . . . . . . . . . . . . . . . . . . 8-44 Tcl Custom Commands . . . . . . . . . . 9-3
command arguments . . . . . . . . . . 8-3 Trash bin . . . . . . . . . . . . . . . . . . . . 2-26
command structure . . . . . . . . . . . . 8-3
defined . . . . . . . . . . . . . . . . . . . . . 8-2 W
I/O . . . . . . . . . . . . . . . . . . . . . . . 8-24
I/O channels . . . . . . . . . . . . . . . . 8-30 Wire EDM
math operators . . . . . . . . . . . . . . 8-15 2-axis . . . . . . . . . . . . . . . . . . . . . . 4-2
order of word interpretation . . . . . 8-5 4-axis . . . . . . . . . . . . . . . . . . . . . . 4-2
procedures . . . . . . . . . . . . . . . . . 8-19 controller type . . . . . . . . . . . . . . . 4-2
program flow control . . . . . . . . . . 8-41 generic . . . . . . . . . . . . . . . . . . 4-2
reference manuals . . . . . . . . . . . 8-54 library . . . . . . . . . . . . . . . . . . 4-2
scripts . . . . . . . . . . . . . . . . . . . . 8-18 user’s . . . . . . . . . . . . . . . . . . . 4-2
comments . . . . . . . . . . . . . . 8-18

Index-2 Post Building Techniques – Student Guide mt11060_s — NX 8 — Copyright 2011 Siemens PLM Software
Reference tear-out pages
These reference tear-out pages are provided for your convenience. The
following pages are included:
• An overview of Siemens Learning Advantage

• A Student Profile sheet that your instructor may have you complete at
the beginning of the course

• The course agenda

• Evaluation sheets for the course delivery and the course materials. You
may also be given information about filling these out online.
This page left blank intentionally.
Siemens Learning Advantage
Maximize your PLM investment with e-Learning!

Siemens Learning Advantage is a convenient,


easy to use e-Learning portal that provides cost-
and time-effective methods for users to gain
skills and knowledge of Siemens PLM Software
solutions. It contains an unparalleled library
of self-paced courses and assessments, as well
as management tools for companies to measure
learning progress and to administer learning
programs.
Competitive advantage
Siemens Learning Advantage courses present consistent methods and concepts approved
by Siemens. Our course development teams work closely with Product Development to
ensure that prescribed processes reflect the intended product usage and industry best
practices. No other training provider can make this claim! And because our learning
products are coordinated with Siemens product releases, you can be confident that
training will be delivered in time for your upgrade.
Benefits include:
• Simple user interface requiring only a standard internet browser.
• On-demand internet access to self-paced courses and assessments.
• Extensive self-paced library supporting a broad range of Siemens products and
versions.
• Online learning management system for tracking and reporting training progress.
• Memberships renew on an annual basis and provide uninterrupted access to courses.

Learn more about Siemens Learning Advantage by visiting our web site or contact your
Siemens PLM Software sales representative for purchase information.
This page left blank intentionally.
PLM Software
www.siemens.com/plm

Student Profile
To stay in touch with our customers, we are asking for some background information. We will keep this information confidential and
will not share this with anyone outside Education Services. Please print your information.

Your name _____________________________________________________________________________________ U.S. citizen? Yes No

Course title: Post Building Techniques Dates: _____________ thru _____________

Hotel/motel while training: __________________________________________________ Planned departure time after class: ________________

Employer _____________________________________________________________ Location ______________________________________________

Supervisor/manager: _______________________________________________ Emergency contact phone: _________________________________

Your job title and responsibilities ______________________________________________________________________________________________

_____________________________________________________________________________________________________________________________

Industry: Automotive Aerospace Consumer products Machining Tooling Medical Other

Types of products/parts/data that you work with: ________________________________________________________________________________

Platform (operating system): ______________________________________________

Reason for training: __________________________________________________________________________________________________________

List any training you have had for Siemens PLM Software products, such as NX, I-deas, Imageware, Teamcenter Manufacturing,
Teamcenter Engineering, Teamcenter Enterprise, Tecnomatix, or Dimensional Management/Visualization.

Instructor-led
Software Training provided by: When Course name
or self-paced?

Other CAD/CAM/CAE/PLM software you have used: ____________________________________________________________________________

Please indicate your experience with the following:

Thank you for your participation. We hope our training meets your expectations.
This page left blank intentionally.
Course agenda — Post Building Techniques
Day 1 Morning

• Introduction & course overview


• Lesson 1 – The NX Post postprocessor
• Lesson 2 – Build a postprocessor with Post Builder

Afternoon

• Lesson 2 – Build a postprocessor with Post Builder

Day 2 Morning

• Lesson 2 – Build a postprocessor with Post Builder


• Lesson 3 – Units-only subposts

Afternoon

• Lesson 4 – Post Builder for Wire EDM applications


• Lesson 5 – Post Builder for 4-axis and 5-axis mills

Day 3 Morning

• Lesson 6 – Post Builder for lathe applications


• Lesson 7 – Create Mill-Turn postprocessors

Afternoon

• Lesson 7 – Create Mill-Turn postprocessors

Day 4 Morning

• Lesson 8 – Tcl basics for Post Builder


• Lesson 9 – Custom commands

Afternoon

• Lesson 10 – User defined events and user defined cycles


• Lesson 11 – Virtual NC controller
• Lesson 12 – Postprocessing with a Siemens controller
• Lesson 13 – Create a macro with Post Builder
This page left blank intentionally.
Siemens PLM Software – Delivery Evaluation
Your name: ____________________________________________________________
Course title: Post Building Techniques
Course #: mt11060 Dates: _____________________________
Instructor: _____________________________________________________________
Siemens PLM Software – Courseware Evaluation
Your name: ____________________________________________________________
Course title: Post Building Techniques
Course #: mt11060 Dates: _____________________________

Name (optional): _____________________________________ Location/room ________________

If you would prefer to fill out an evaluation online, please go to the following URL:
http://training.industrysoftware.automation.siemens.com/eval/

Session ID: ______________________ (provided by instructor). Must be completed within two weeks.

Thank you for your business. We hope you will consider us for your future training and
professional development.

You might also like