Macro to Move/Rotate/Scale any selection in a single operation.

Started by bdeck, February 24, 2026, 06:33:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

(Previously posted in General DesignCAD Topics)

The mm.d3m macro shown below performs a move/rotate/scale of any selection in a single operation.

If the user
1} selects one or more entities,
2} then runs the macro ,
3} then sets two points to define the starting location, orientation, and scale,
4} then sets two more points to define the final location, orientation, and scale,
5} (plus a fifth random point or press of the Enter key to confirm point locations)

the macro then performs a point relative move/rotate/scale of the selected entities.

It is particularly useful (and quick) for arranging images of different sizes into a page of (eg) uniformly sized images. But I find a reason to use it just about every day to rescale something.

Because I am running out of shortcut keys, I run "MM" from the command line; hence the short and simple file name.


''' mm.d3m  DC6 style Move/Scale macro for 4 point moves  version 0.1 bdeck 2019
'
'
' Select object; run macro.
' Set  2 points for selection orighinal location, orientation, and scale.
' Set  2 points for selection target location, orientation, and scale.
' Then set a fifth point or hit enter to execute (or consecutive Esc to edit or exit).
' (This final step allows you to check your work before committing to the move)
'
'
' Note that sys(36) prevents dialog box cleanup errors.
' Sys(1)=0 does not clean up set points in preset point mode.

If Sys(80) < 1 Then
message "4-Point Move. No entities selected"
End
endif

Sys(41) = 0
dim x(6),y(6), z(6)
n=sys(1)

if n> 4 then n=4   ' for preset point mode only **********************
if (n=4) then goto gottem 'use correctly set points

retry:
setpoint "Move/Scale Macro --  Set total of 2 source points,   2 target points,  plus a fifth point or ENTER to confirm" 5
n=sys(1)
if n=0 then goto cleanup
if n<4 then goto retry
if n>4 then n=4

gottem:

sflag=sys(36)
sys(36)=1

for i=1 to n
pointval x(i) y(i) z(i) i
next i
sys(1)=0

if n=4 then

>SetHandle
{
<Pointxyz [x(1), y(1), z(1)]
<Pointxyz [x(2), y(2), z(2)]
}


>Move
{
<Type 0 ' Rotated and scaled
<Pointxyz [x(3), y(3), z(3)]
<Pointxyz [x(4), y(4), z(4)]
}

endif

cleanup:

sys(36)=sflag
sys(1)=0 'clean up unused points
REGEN


For simple Unscaled 2-point or 4-point moves,  I use a keyboard shortcut to access the "M.d3m" macro found here: http://forum.designcad.com/index.php?topic=322.msg1404#msg1404

JJG

Hy Bdeck, fine !

note : "It is particularly useful (and quick) for arranging images of different sizes into a page of (eg) uniformly sized images." : to do that, Word is particulary efficient too !