How to draw Line Profile on invisible image?
Hi guys,
I create an invisible image and I want to draw Line Profile on it .
But it pop up an error message about
'Unable to cast COM object of type 'MediaCy.IQL.Engine.McImageClass' to interface type 'MediaCy.IQL.Application.IMcDocument'.

[code]
Can I draw Line Profile on invisible image?
Please help me to solve this annoying problem, thanks!
I create an invisible image and I want to draw Line Profile on it .
But it pop up an error message about
'Unable to cast COM object of type 'MediaCy.IQL.Engine.McImageClass' to interface type 'MediaCy.IQL.Application.IMcDocument'.

[code]
Dim im As McImage = ThisApplication.ActiveImage Dim invisible_im As McImage = im.Duplicate(mcImageCreateFlags.mcicfNotVisible) 'Create invisible image With Measure.LineProfile.ProfileCommands.Add(Nothing) .ProfileType = LineProfile.ProfileTypes.Line .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(1689, 1116)) .Points.Add(New System.Drawing.PointF(1952, 1116)) .Angle = 0R .CreateEngine = true .Run(invisible_im) 'Draw Line Profile on invisible image
End With
Can I draw Line Profile on invisible image?
Please help me to solve this annoying problem, thanks!
0
Answers
-
Hi Tony,
Line Profile commands works with IMcDocument (visible image or image set) and will not work with invisible image. As workaround you can create McLines instance attached to invisible image (Ex: Dim lines As McLines = McApplication.ThisApplication.CreateOperator("McLines", MyInvisibleImage, "MYLines")) and use lines.Profiles to analyze edges.
Thanks,
Nikita.0 -
Hi Tony,
With small modifications in the macro you can create invisible document and use it with the line profile commands:Public Function InvisibleDocument() As SimpleScript InvisibleDocument = New SimpleScript Dim im1, doc1, win1 With Automate.ScriptingCommands.CodeCommand(InvisibleDocument) If .Run() Then ' User Code Here im1 = .Application.ActiveImage.Duplicate(mcImageCreateFlags.mcicfNotVisible) 'create invisible image doc1 = .Application.Documents.Add(im1) 'create invisible document End If End With With Measure.LineProfile.ProfileCommands.RemoveAll(InvisibleDocument) .CreateEngine = True 'force to create line profile engine for invisible document .Run(doc1) End With With Measure.LineProfile.ProfileCommands.Add(InvisibleDocument) .Text = "Add Profile" .ProfileType = LineProfile.ProfileTypes.Line .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(10F,10F)) .Points.Add(New System.Drawing.PointF(100F,100F)) .Angle = 0R .Run(doc1) End With With Application.DocumentCommands.Show(InvisibleDocument) .Run(doc1, win1)'show document End With End Function
Key modifications:
1) create invisible document from the invisible imagedoc1 = .Application.Documents.Add(im1) 'create invisible document
2) force to create line profile engine (.CreateEngine = True should be set on the first line profile command).CreateEngine = True
Remember to close invisible document to free up the memory.
Nikita.
0 -
Thanks Nikita,
This is of great help to me!
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions