Accessing Machine Definition Parameters in MP.NET
Views
MP.NET developers have always been able to use the Api.MPParam
function to query MP operation parameters in their MP.NET post. However, this function does not let developers query machine definition parameters or parameters for individual components. Three new functions have been added to MP.NET to provide this functionality.
-
One function lets the post developer query specific components or the machine definition itself for parameter values.
-
Two additional functions address the need to identify the specific component whose parameters the developer wishes to query. One function queries the axis combination in which the component resides; the second function identifies components based on their relationship with a known component.
Api.MachineDefInfo function
Use this command to query the machine definition or specific components for parameter values. This is the main function for accessing the machine definition parameters that are available to MP posts (parameters 17000–17999 and 60000–64999). Use this with a single argument to query general machine definition settings or supply a component ID as the second argument to query a specific component.
The general form of the function is as follows:
Api.MachineDefInfo (paramNum [, componentID])
The functions are defined below:
-
paramNum
is the number of the machine definition parameter to access. This can be either a number or the name of a numeric token. -
componentID
(optional) is the ID of the component to access. For example, your machine definition might have several of the same type of component, such as linear axes, turrets, or spindles. Mastercam uses this number to select the specific machine definition component to query.If this argument is not supplied, Mastercam will query the general machine settings. These include the information in the General Machine Parameters dialog box and the main Machine Definition Manager dialog box.
Typically you will get the desired component ID with the Api.AxisCombo
function or the Api.GetRelatedComponentID
function.
Api.AxisCombo function
Use this function to get the component ID of either an axis combination or a component within an axis combination. Typically the ID that is returned is used as input for the Api.MachineDefInfo
function.
The general form of the function is as follows:
Api.AxisCombo (mode, spindleID, streamID [, componentType])
The functions are defined below:
-
mode
specifies the information that will be returned by the function:Title
, orComponentID
.-
Specify
Title
to return the name of the axis combination. -
Specify
ComponentID
to return the ID of either a component in the axis combination or the axis combination itself.Do not add quote marks around this argument.
-
-
spindleID
is the number of the spindle in the axis combination that you are querying. TheSpindleID
token is commonly used for this purpose. -
streamID
is the number of the stream associated with the axis combination that you are querying. TheStreamID
token is commonly used for this purpose.Note that in the machine definition (*.mcam-lmd file), the stream IDs are 1-based (in other words, on a dual-stream machine, the streams are 1 and 2), but inside MP.NET they are zero-based (the two streams are 0 and 1). This function uses the zero-based MP.NET stream IDs.
-
ComponentType
(optional) specifies the type of component in the axis combination that you are querying—for example,CAxis
,Chuck
, orTurret
. A complete list of allowed types is presented below.-
If you include this argument, Mastercam returns the ID of the component of that type that is present in the axis combination.
-
If you omit this argument, Mastercam returns the ID of the axis combination itself.
-
Specifying the component type
The allowable component types are listed here. The value specified with the function must exactly match the list below. Do not use quote marks.
-
XAxis
-
YAxis
-
ZAxis
-
AAxis
-
BAxis
-
CAxis
-
RectangleTable
-
Fixture
-
Vise
-
Chuck
-
ColletChuck
-
MultiHead
-
PiggyBack
-
WireUpperGuide
-
WireLowerGuide
-
ToolSpindle
-
MultiTool
-
Turret
-
AggregateHead
-
DrillBlock
-
GangTool
-
MTTurret
These are the component types that are considered to be part of an axis combination. For example, chuck jaws or collets are not considered part of the axis combination and their IDs cannot be retrieved with this function. Each axis combination should only contain one of each type of component.
-
If no component of the requested type is present, then nothing will be returned.
-
If a
ComponentType
argument is supplied, it does not matter what the first argument is (Title
orComponentID
)—Mastercam will always return the component ID.
Api.GetRelatedComponentID function
Use this function to get the ID of a component based on its relationship with another component—for example, a child or sibling component. You can also use this function to get the ID of a component that is not in an axis combination. Typically the ID that is returned is used as input for the Api.MachineDefInfo
function.
The general form of the function is Api.GetRelatedComponentID (navigationType, componentID [, generation])
.
The functions are defined below:
-
navigationType
specifes the relationship between the component whose ID is supplied and the component that you are querying. Allowable values areParent
,FirstChild
,NextSibling
,PreviousSibling
, orRoot
. Do not add quote marks around this argument. -
componentID
is the ID of the base component in the relationship. -
generation
(optional) represents the generation to access. If this argument is not supplied, it defaults to 1. For example, ifnavigationType
isFirstChild
and this argument is 2, then Mastercam will find the first child of original starting component and then the first child of that component, returning its ID.
Comments
You must be logged in to leave and view comments.