Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

3ds max 2023 uses maxscript to call the createOLEObject interface to read Excel and reports an error.

243202504
Enthusiast

3ds max 2023 uses maxscript to call the createOLEObject interface to read Excel and reports an error.

243202504
Enthusiast
Enthusiast

local conditionFilePath = @"D:\conditionscel.xlsx"
Xlsx = CreateOLEObject "Excel.Application"
Xlsx.application.Workbooks.open(conditionFilePath)

 

***------ error ------*****
-- Security Exception: MAXScript command embedded in the current scene could be unsafe and its execution has been blocked for the current 3ds Max session: createOLEObject "Excel.Application"
***------ error ------*****

 

Seems since max 2022 , The Safe Scene Script Execution settings can be found in the Security tab of the Preferences dialog The commands being blocked fall into these categories:
1) Maxscript system commands: these are commands that allow access to resources outside the 3ds Max scene, such as file system, process execution, network and internet. Examples include DosCommand, ShellLaunch, createOLEObject, LoadDllsFromDir.

 

 

I have turned off the anti-virus security tool function that comes with Max, but the error still occurs. Is there any solution. Two aspects: first, is there any modification of certain settings that can allow max2023 to successfully call this command; second, is there any other way to read excel data in max. ps: I read excel data for project specifications, usually by storing string strings in the shell to limit units or coordinates or numbers. My maxscript can run normally in max2017. But max2023 will report an error in this line. In fact, there are other errors reported, that is, the plug-in UI interface calls DoNet, and the UI cannot be displayed unless the anti-virus is turned off. But after turning off the anti-virus, excel still cannot be read in max2023.

 

 

Thank you everyone, please help me!

0 Likes
Reply
Accepted solutions (1)
1,213 Views
14 Replies
Replies (14)

243202504
Enthusiast
Enthusiast

@denisT.MaxDoctor  Hello! Dear Sir! Can u help me about this question? Thanks! xD

0 Likes

denisT.MaxDoctor
Advisor
Advisor

Sure, it's a Security issue. But there are settings (Security Preferences) you can play with, and there must be a reason why it is blocked.

How do you launch the tool? Is it an MCR, or startup script, or something else?

 

denisT.MaxDoctor
Advisor
Advisor

Could you provide an example Excel file to read?  
Do you only need to read or do you also need to write?

0 Likes

243202504
Enthusiast
Enthusiast

Through MCR, read the mse, and then the mse file is mainly the UI architecture, and then read the main code from the mse file, and the main code is the ms file.

0 Likes

243202504
Enthusiast
Enthusiast

It works normally in max2017. In max2022, I have turned off the built-in anti-virus(settings (Security Preferences)) in the security options, because I can’t get out of the UI interface without turning it off, but the function of reading data in excel will still be blocked by max.

0 Likes

denisT.MaxDoctor
Advisor
Advisor

MCR is auto-executable, and it calls an MSE (encrypted script), which could possibly call OLE... this is limited by the new security mechanics.
We need to change one of those three things to make it work.

My suggestion is to not use MSE. I've always been against using it.

The second thing is to be able to do it without creation of OLE object.

But you didn't send me an example file to try it.

 

0 Likes

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

I double-checked and see now that there is no problem with creating an OLE object while running (startup) MAX 2023. The only restriction is that it must not be called from MSE.

So, there are two simple solutions:

1. don't use MSE
2. don't create the OLE object at startup; do it on the fly when you run the main tool.

0 Likes

243202504
Enthusiast
Enthusiast

thanks for your reply!
I tried to remove the mse, read the UI ms file directly from mcr, and read the main code from the UI ms file. And if I call the previous method for reading xlsx directly into the main tool, an error will still be reported.
The parts of my main UI that do not involve xlsx can run normally when clicking buttons. Only those parts that need to use OLE will be blocked by max.
I have also tried running OLE related directly in max2023, and it can indeed be executed.

0 Likes

denisT.MaxDoctor
Advisor
Advisor

 

 

xlsx = @"C:\temp\Tools\ExcelDataReader-3.6.0\test\Resources\ColumnWidthsTest.xlsx"
(
	xobj = CreateOLEObject "Excel.Application"
	xobj.Application.Workbooks.open xlsx
	xobj.visible = false

	data = #()
	xx = xobj.ActiveSheet
	for y = 1 to xx.UsedRange.Rows.count do
		for x = 1 to xx.UsedRange.Columns.count 
			where (v = (xx.Cells x y).Value) != undefined do append data #([x,y], v)

	xobj.Application.ActiveWorkbook.Close()
	xobj.quit()
	releaseOLEObject xobj
	releaseAllOLEObjects()

	data
)

 

 

 

This is a simple example that should work as it is.... (you can use your xlsx file).
Thus, we may read xlsx. It remains only to find the right place to call it.

 

So, the question is not what to call, but how to call and from where.

denisT.MaxDoctor
Advisor
Advisor

the system says:

"MAXScript command embedded in the current scene could be unsafe..."

 

It means the code you try to call is embedded somehow in the scene... How? Persistent global, attribute, etc.?

0 Likes

243202504
Enthusiast
Enthusiast
that  code  said:"this is based on stdplugs\stdscripts\baseLib\rolloutCreator.ms"

Regarding the xlsx reading part, our code is consistent. Now when I use it in max2017, it works normally, but when I use it in 2022, I get an error.
If it still doesn't work, I may switch to reading txt files, but txt is not intuitive enough. I have also finished writing the relevant methods, and use the openFile function to read the parameters separated by “;”.
 
0 Likes

denisT.MaxDoctor
Advisor
Advisor

 ...the code you try to call is embedded somehow in the scene... How? Persistent global, attribute, etc.?

 

You didn't answer my question. "Embedded" means that the code is saved in a file, and it is loaded with the file. What are you doing for that?

0 Likes

denisT.MaxDoctor
Advisor
Advisor

@243202504 wrote:

If it still doesn't work, I may switch to reading txt files...
 

In this case, it would mean you've wasted my time. 😎

0 Likes

243202504
Enthusiast
Enthusiast

I read the original code, read the main code through a fn in the UI interface, and then readline, and then processed various strings such as matchpattern, append, findstring, etc. to find the strings such as "_check" in the main code, and then through Window .addText to create elements on the UI. Since English is not my native language, I am very sorry for the misunderstanding caused during communication. Then because I have no way to send the code, I can only express it like this, but I roughly understand the meaning, that is, max2022 is stricter about the security of this kind of loaded code, so I cannot read it through this method. Because the code format has been fixed and I am also the person who took over, I cannot solve it with small modifications.

0 Likes