code conversion
Hi,
I'm working on a project to convert several macros to the new version of Image-Pro (9.1).
My client was using, if i'm correct, version 7.
I'm a .NET programmer, so i'm familiar with the .NET framework, and I was able to rebuilt some logical part of the code.
But now i'm stuck on some command that was use in the last version to start some measure action.
ret = IpMeasShow(MEAS_SHOWADVANCED)
ret = IpMeasTool(MEAS_AREA)
ret = IpMeasGet(GETNUMOBJ, 0, CompteurMesure)
ret = IpMacroStop("Tracer le contour du LUMEN puis - Continue",0)
ret = IpMeasGet(GETNUMOBJ, 0, CompteurMesure2)
I though using "Record macro" to get the command to use, but I don't know Image-Pro, so I don't what is the equivalent of IpMeasShow(MEAS_SHOWADVANCED) in the GUI.
Can someone can point me each command to the equivalent in the GUI...or what is the way, in the macro of the new version to execute the same command ?
Thanks in advance.
I'm working on a project to convert several macros to the new version of Image-Pro (9.1).
My client was using, if i'm correct, version 7.
I'm a .NET programmer, so i'm familiar with the .NET framework, and I was able to rebuilt some logical part of the code.
But now i'm stuck on some command that was use in the last version to start some measure action.
ret = IpMeasShow(MEAS_SHOWADVANCED)
ret = IpMeasTool(MEAS_AREA)
ret = IpMeasGet(GETNUMOBJ, 0, CompteurMesure)
ret = IpMacroStop("Tracer le contour du LUMEN puis - Continue",0)
ret = IpMeasGet(GETNUMOBJ, 0, CompteurMesure2)
I though using "Record macro" to get the command to use, but I don't know Image-Pro, so I don't what is the equivalent of IpMeasShow(MEAS_SHOWADVANCED) in the GUI.
Can someone can point me each command to the equivalent in the GUI...or what is the way, in the macro of the new version to execute the same command ?
Thanks in advance.
0
Best Answers
-
Image-Pro Plus had different UI for manual measurements, Image-Pro Premier treats manual and Count/Size measurements the same, so you may not need the equivalent of IpMeasShow(MEAS_SHOWADVANCED) in Premier. Though you may just show Data Table (recorded command):
Public Function ShowDataTable() As SimpleScript ShowDataTable = New SimpleScript With Measure.Measurements.Gadgets.DataTable(ShowDataTable) .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked .Run() End With End Function
The next step prompts user to draw an object, it can be done using the equivalent macro in Premier:Public Function DrawNewObject() As SimpleScript DrawNewObject = New SimpleScript Dim image1, meas1 With Application.RibbonCommands.SelectRibbonTab(DrawNewObject) .TabName = "Measure" .Run() End With With Application.DocumentCommands.ActiveImage(DrawNewObject) .Run(image1) End With With Measure.MeasurementsCommands.Add(DrawNewObject) .Prompt = "Please draw new object." .MeasurementType = McMeasurements.enumMMSTypes.mmtsPolygon .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .FeatureName = "P1" .SnapFeature = False .Interactive = True .Run(image1, meas1) End With End Function
You can check the forum for other posts handling measurements from macros:
http://forums.mediacy.com/discussion/10/how-to-access-measurement-data-in-your-app/p1
Regards,
Yuri0 -
If you want to create multiple objects, then you should use different approach. In Premier any command can be made interactive by activating Interactive property:
Public Function DrawMultipleObjects() As SimpleScript DrawMultipleObjects = New SimpleScript With Measure.Measurements.ToolsCommands.Polygon(DrawMultipleObjects) .Prompt = "Pleasse draw multiple objects and click Ok." .Tool = eMMTool.Polygon .Interactive = True .Run(ThisApplication.ActiveImage) End With End Function
There is also specific command (analog of IpMacroStop) that shows interaction prompt:Public Function ShowInteractivePrompt() As SimpleScript ShowInteractivePrompt = New SimpleScript With Automate.ScriptingCommands.Interaction(ShowInteractivePrompt) .Prompt = "Do something, then click Ok." .Interactive = True .Run(ThisApplication.ActiveImage, Nothing) End With End Function
Yuri0
Answers
thanks for your answer.
I used your snippet of DrawNewObject in my macro, it works, but I need to change a behavior.
With your example, I prompt the user to draw an object (polygon). To close their measure the user has to "double-click" on his last point...but this action raise the click action on the button OK of the prompt message.
I need that the user can add any measure he wants and then, press OK on the prompt message to go to the next step.
My macro ask the user to draw 3 types of measurement, and in each type he must be able to add any measure he wants.
How can I do that ?
In the code I have from IPP 7 it looks like IpMacroStop was the command to "stop the macro" until the user click OK.
Thanks in advance.
Martin
thanks again for your fast answer...that do the job as I expected.
With the "DrawSimpleObject" I used before, I was able to get reference to the object of the measure created...and then rename it into the data table.
Now, with the "DrawMultipleObject", is there a way to get the collection of created measure ? I need to all rename it, and soon, assign a specific class for the bunch of measure created.
If there is no way to get the collection of created measure after the user press ok, I thought there is a way to get all data from the data table ?
I tried to record a rename of measure but the record seems to do not work with that action.
Thanks for your time,
Martin
You can access all existing measurement features directly, check this post as example: http://forums.mediacy.com/discussion/comment/93/#Comment_93
You can get the number of features before and after your macro and rename only added features.
Yuri