DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Replacment for GraphObjNew / GraphObjOpen

Solved!
Go to solution

Hello everyone,

I just switched from DIAdem 2015 to DIAdem 2021 and I wanted to execute a script but got an error at the point where I use GraphObjNew:

 

Call GraphObjNew("FreeGraph","Metafile2")
Call GraphObjOpen("Metafile2")
MtaFileName = "@@T8@@"
MtaRelPos = "r-bot."
MtaHeight = 30.0
MtaRatioAdapt = 0
MtaWidth = 1/MtaRatio*MtaHeight
MtaPosX = 50.0-MtaWidth/2
MtaPosY = 77.97
MtaBackColor = ""
MtaBackRGB = 0
MtaEmbedded = 0
Call GraphObjClose("Metafile2")

 

The error message says: Variable is undefined. Is there another command that replaced GraphObjNew and GraphObjOpen, or can you recommend another workaround?

 

Thanks a lot for your help!

0 Kudos
Message 1 of 7
(1,677 Views)

Hello Z2424,

Hope you are doing well,

Is it possible that the error pops up when you are double-clicking on  .VBS file and trying to run from windows?

If yes, try to load the file to the DIAdem Script panel and then run it.

 

Best Regards

0 Kudos
Message 2 of 7
(1,648 Views)

Hi Z,

 

No, I'm afraid DIAdem has obsoleted all the old GraphObj...() commands and variables, and now all the REPORT panel automization must be accomplished with the "Report" object.  Is the code you sent in basically all that you need to upgrade, or are you sitting on thousands of lines of code that have "GraphObj..." in them?

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 3 of 7
(1,638 Views)

Hello Brad,

thank you for your answer. Luckily, it's only this bit I sent in my initial request. As you might have seen, I'm trying to include a picture in a report. It should have a height of 30.0 and the width should be according to the original ratio. Is there a way to get the original image ratio (height/width)?

Regards

Z2424

0 Kudos
Message 4 of 7
(1,627 Views)
Solution
Accepted by topic author Z2424

Hi Z,

 

I believe this script does what your GraphObj...() approach was doing.  It should at the very least provide a roadmap.

OPTION EXPLICIT
Dim Sheet, Image, MRatio, MHeight, MWidth
T8 = "EXAMPLE4.PNG"
Set Sheet = Report.Sheets(1)
Set Image = Sheet.Objects("Metafile2")
Image.FileName = "@@T8@@"
Image.Embedded = False
Image.BackgroundColor.ColorIndex = eColorIndexNone
Image.UseOriginalRatio = True
MRatio = Image.OriginalRatio
MHeight = 30.0
MWidth = 1/MRatio*MHeight
Image.Position.ByCoordinate.Height = MHeight
Image.Position.ByCoordinate.Width = MWidth
Image.Position.ByCoordinate.X2 = 50.0-MWidth/2
Image.Position.ByCoordinate.Y2 = 77.97
Call Report.Refresh()

Cheers,

Brad Turpin

Principal Technical Support Engineer
NI

Message 5 of 7
(1,618 Views)

Hi again Z,

 

The script I just sent assumes that you have an image object named "Metafile2" on sheet1 of your loaded REPORT layout.  You can load this layout I was testing with if my code doesn't mesh perfectly with your layout.  It wasn't obvious from your code which sheet you were operating on.

 

Brad Turpin

Principal Technical Support Engineer
NI

Message 6 of 7
(1,616 Views)

Hello Brad,

thanks again for your help. With your support I got my script running with the new DIAdem version and everything is running as intended.

Best regards!

0 Kudos
Message 7 of 7
(1,604 Views)