DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Snap Grid ignored in Macros?

Started by Lar, November 23, 2017, 12:20:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lar



Hi all,

Does anyone know how to emulate a manual mouse click in a macro. I'm trying to write a macro that sets points for commands but I want them to snap to the nearest grid point, like when clicking manually .


When I set points using the point commands (eg, <pointXYZ, pointREL, etc) they do not snap the grid.

I tried using Preset Point code but same thing happens.

Lar

JJG

Hi Lar,

My side, I have some macros using snap grid, such the following one :

COUCHE=sys(3) 'Store activ layer
GM=sys(17) 'Store snap grid statement.
SP=sys(48) 'Store snap preview statement.
T=sys(438) 'Dimension text size
Gx=sys(19) 'Store Minor Display Grid spacing along x
Gy=sys(20) 'Store Minor Display Grid spacing along y

sys(17)=0 'disable snap grid
sys(1016)=1 'Synchronize Snap Grid to Display Grid [0=off, 1=on]
sys(19)=3*T 'Minor Display Grid spacing along x
sys(20)=3*T 'Minor Display Grid spacing along y

If Not(Sys(48)) Then
>SnapPreviewMode
{
}
End If

SET1:
sys(996) = 1 'Enhanced Esc Key Behavior
mes$= "Set points: 1,2-Points of cotation, (3-position of text)"
SETPOINT mes$ 1
IF sys(1) < 1 THEN GOTO SET1
Pointval Ax Ay Az 1

SET2:
mes$= "Set points: 1,2-Points of cotation, (3-position of text)"
SETPOINT mes$ 1
IF sys(1) < 1 THEN GOTO SET2
Pointval Bx By Bz 1

sys(17)=1 'activ snap grid

sys(1)=0 'Nber of setting points.

>Dimension
{
  <Axis 0
  <PointXYZ [Ax, Ay, Az]
  <PointXYZ [Bx, By, Bz]
  <incomplete
'  <Color 0,0,0
'  <Layer 11
'  <Orientation 0
'  <Precision 1
'  <Format 0
'  <Location 1
'  <ToleranceType 0
'  <ToleranceSize 5.000000000000000e-001
'  <ToleranceLow
'  <ToleranceHigh
'  <Tolerance
'  <Suffix "0"
'  <Prefix "0"
'  <Font "Arial"
'  <VectorFont "Simplex_Win"
'  <FontType 0
'  <Size 3.000000000000000e+000
'  <Type 0
'  <Fix 0
'  <Gap 1.000000000000000e+000
'  <Length 2.000000000000000e+000
'  <OverShoot 5.000000000000000e-001
'  <Arrowhead 5
'  <ArrowSize 7.500000000000000e-001
'  <LinePosition 0
'  <Multiplier 0
  }

sys(17)=GM 'restore initial setting of snap grid statement
sys(19)=Gx 'restore initial setting of  Minor Display Grid spacing along x
sys(20)=Gy 'restore initial setting of  Minor Display Grid spacing along y
sys(48)=SP 'restore initial setting of snap preview statement

End.



Hope it can help you...
;)

Lar

Thanks JJG,

However, your macro wouldn't apply to my situation, mainly because the user sets the 3rd dimension point manually after snapping is turned back on, so it would stick to the snap grid. My issue is that, with snapping enabled, when a macro sets a point, that point goes exactly where the macro tells it to go. I want it to snap to the nearest grid point, like how it does if the user had set that point manually.

To further clarify, in your macro, when the dimension command uses the 2 points the user had set (when the grid is off) I would want them to stick to the snap grid (because the grid is turned back on when the macro runs the dimension command). However, they don't... so it only confirms my issue.

The good news, though, is that, after trying my best to avoid the inevitable, I finally bit the bullet and wrote the math it took to drop the points on my own 1/16" grid. The whole point was to "quantize" every point in drawing, since dcad's points somehow goes astray when you zoom way down, especially for solids I reconstruct manually.

It would still be better to use dcad's snap grid, since it can be angled or radial... ...well, maybe not, cus tiny grids often cause dcad to run "out of memory".


Lar