Subscribe to this thread
Home - General / All posts - UI Scripting M8 - automatic way to confirm ?
vincent

1,774 post(s)
#01-May-19 16:20

Hi,

I'm using UI scripting to Copy/Paste a surface. When running the code, a confirm dialog is displayed on top, and I have to manually confirm this dialog "Surface size is 123456 x 123456 pixels. Paste Anyway ? "

Is it posible to programatically reach this dialog and push the "ok" button by code ?

Image of dialog is attached.

I know I can manually turn off the global option named "Confirm expanding images or surfaces when pasting". But it doesn't seems to apply to this operation. It changes nothing.

Thank you.

Attachments:
paste_anyway.jpg

tjhb

8,771 post(s)
#02-May-19 03:38

Vincent,

Is it posible to programatically reach this dialog...

Not from Manifold itself. I have banged my head against this in the past too (and sent in a request for it to be changed).

...and push the "ok" button by code ?

...But yes, if you really needed to. I wound up using the WScript.Shell.SendKeys method (writing from vbscript). A terrible kludge, tricky to use, and fragile since a key press can only be sent to the currently active window (system-wide). That raises timing issues and limits processing to one instance of Manifold at a time. Plus you have to keep your hands well away from the keyboard until everything is finished.

I've attached the vbscript function I used for interpolating like this (2011-2012) in case it's still useful. It was part of a long script for batch processing, which worked at the time. But I hope it isn't still useful because...


More recently I realised I hadn't thought about it hard enough--or not in the right way.

Instead of using Paste as Surface via UI scripting, I would recommend using the Raster Extension functions in Manifold 8 SQL.*

For example, TriangulationContours(drawing, column, corners, g) and TriangulationContours(drawing, column, corners, x, y) implement the same algorithm as the "Triangulation adjusted for contours" method (triangulation + DEST) in Paste as Surface.

The general approach for those functions is to create a blank surface first, covering your target area, then interpolate a height for each pixel. It may seem slow to do this pixel-by-pixel, but I have tested and found these functions at least as fast as Paste as Surface, possibly slightly faster. And they don't need use UI scripting, and... they don't raise the "Paste as anyway?" modal dialog! Straight through, regardless of surface size.

I have some handwritten notes from the testing that I can look out if that is helpful.


*What I would really recommend is to use Manifold 9 instead, not least because it executes in parallel, and is many times faster. The above assumes you want or need to use Manifold 8 for some reason.

Attachments:
PasteAsSurface.txt

vincent

1,774 post(s)
#02-May-19 13:15

Instead of using Paste as Surface via UI scripting, I would recommend using the Raster Extension functions in Manifold 8 SQL.*

That is a good idea Tim. I should be able to implement that.

What I would really recommend is to use Manifold 9 instead, not least because it executes in parallel, and is many times faster

I don't have the time to learn programming with 9 at this moment. 8 is fast enough for our purposes right now.

Thank you !

vincent

1,774 post(s)
#02-May-19 15:31

Creating the surface goes like this

//javascript

function Main() {

var DCS = Document.ComponentSet ;

var drawing  = DCS.Item("copy") ; 

var CS = drawing.CoordinateSystem ;

var bbox = drawing.ObjectSet.Box ;

var xmin = bbox.Xmin - 200 ;

var xmax = bbox.Xmax + 200 ;

var ymin = bbox.Ymin -200 ;

var ymax = bbox.Ymax + 200;

var stepX = 1;

var stepY = 1;

var nx = Math.round((xmax - xmin)/stepX) + 1 ;

var ny = Math.round((ymax - ymin)/stepY) + 1 ;

var surface = Document.NewSurface("Surface", nx, ny, ValueTypeFloat64, CS, 1);

var surfCS = surface.CoordinateSystem ;

surfCS.ParameterSet.Item("localOffsetX").Value = xmin ;

surfCS.ParameterSet.Item("localOffsetY").Value = ymin ;

surfCS.ParameterSet.Item("localScaleX").Value = stepX;

surfCS.ParameterSet.Item("localScaleY").Value = stepY;

}

and the SQL to populate the raster goes like this. I didn't want interpolation. "Copy" is the source drawing.

-- SQL

Update

(Select [a].[score_dvh][b].[Height (I)] from [copy] as [a] 

[Surface] as [b] where [b].[Invisible (I)] = False and Touches 

([a].[ID] 

AssignCoordSys(NewPoint([b].[Center X (I)],[b].[Center Y (I)]),COORDSYS  ("Surface"  as COMPONENT)))

)

Set [Height (I)] = [score_dvh]

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.