Share

Interface: PlacementTool

The PlacementTool Core Interface exposes the Placement Tool's controls and functionality to MAXScript. Available in 3ds Max 2015 and higher.

Properties:

PlacementTool.ActiveMode : boolean : Read|Write

Get/set the Enabled state of the Placement Tool.

When set to False (default), the Placement Tool will be disabled.

When set to True, selected objects can be placed interactively in the scene by performing ray intersection will all other scene geometry, or can be rotated in place depending on the PlacementTool.RotateMode property state.

PlacementTool.RotateMode : boolean : Read|Write

Get/set the state of the Rotate mode.

When set to False (default), moving the mouse in the viewport will perform ray intersection with the scene geometry and place the selection to the intersection point.

When set to True, moving the mouse up and down will rotate the selected objects about their up axes.

PlacementTool.UseBase : boolean : Read|Write

Get/set the state of Use Base As Pivot option.

When set to False (default), the object's pivot will be used to perform the alignment / rotation.

When set to True, the base of the object will be used instead.

PlacementTool.PillowMode : boolean : Read|Write

Get/set the state of the Pillow Mode option.

PlacementTool.AutoParent : boolean : Read|Write

Get/set the state of the Auto-Parent option.

When set to False (default), objects will be placed without changing parent-child relationship.

When set to True, objects will be automatically parented to the object whose surface they were placed on.

PlacementTool.UpAxis : enum : Read|Write 
    UpAxis enums: {#Positive_X | #Positive_Y | #Positive_Z | #Negative_X | #Negative_Y | #Negative_Z}

Get/set the state of the Object Up Axis option.

Default is #Positive_Z .

This option controls which axis of the placed object will be oriented along the surface's normal.

Methods:

<void>PlacementTool.ShowOptionDialog()

Opens the "Placement Settings" options dialog.

Available in 3ds Max 2016 and higher.

<IntegerPtr>PlacementTool.GetCommandMode()

Returns the command mode of the Placement Tool as a Pointer value.

Available in 3ds Max 2016 and higher.

<value>PlacementTool.HitTestScene <ray>Ray

Performs a hit test against the scene using the ray value passed as by-reference In parameter.

<boolean>PlacementTool.PlaceNode <time>Time <node>SelectedNode <point3>Position <point3>Normal <node>TargetNode <boolean>bRotateUpAxisToNormal

Places the specified node on the surface of the specified target at the given time using the Position and Normal values acquired from the PlacementTool.HitTestScene() method.

The Time argument specifies the time at which to evaluate the objects.

The SelectedNode argument provides the node to be placed.

The &Position argument passes the position as a by-reference in parameter.

The &Normal argument passes the Normal vector as a by-reference in parameter.

The TargetNode argument specifies the node whose surface to use for placement.

The bRotateUpAxisToNormal boolean argument specifies whether to orient the up axis (determined by PlacementTool.UpAxis ) of the placed node to the surface normal at the intersection point.

EXAMPLE

(
    resetMaxFile #noprompt
    
 --Create some geometry to test against
    local p = plane width:210 length:210 widthsegs:200 lengthsegs:200 
    local s = sphere radius:50 segs:100 pos:[14,15,-25]
    local n = noiseModifier()
    addModifier p n
    n.strength = [0,0,50]
    n.scale = 50.0

    local theObjects = #() --collect objects to be placed in this array
    for y = -100 to 100 by 5 do
    (
        for x = -100 to 100 by 5 do
        (
            local c = cone pos:[x,y,100] radius1:3 height:5 wirecolor:blue --create a grid of cones above the surfaces
            append theObjects c --collect the cones in the array
        )
    )
    local st = timestamp() --get a time stamp
    for o in theObjects do --loop though all cones
    (
        local result = PlacementTool.HitTestScene (Ray o.pos [0,0,-1]) --intersect a ray down the -Z
        local minDist = 100000.0 --initialize a variable for the minimum distance
        local newPos = o.pos --set the new position to the current position of the current cone
        local newNormal = o.dir --set the new normal to the current direction of the current cone
        local theTarget = undefined
        for i in result do --loop through all results
        (
            local dist = (distance i[2].pos o.pos) --calculate the distance to the hit
            if dist < minDist do  --if it was closer, 
            (
                minDist = dist --set the minimum distance to the current distance value
                newPos = i[2].pos --record the position
                newNormal = i[2].dir --and the normal
                theTarget = i[1] --remember the object that was hit
            )
        )
        if theTarget != undefined do --only place the object if a target was found
            PlacementTool.PlaceNode currentTime o &newPos &newNormal theTarget true
    )
    format "Placement of % objects took % ms.\n" theObjects.count (timestamp()-st) --print the time
)
  ![](../../../../../images/GUID-850899B0-9260-4A82-A231-62D29555F476-low.png)

Was this information helpful?