Get/Set options on invoked action DzUpdateGeometryAction

I am currently trying to figure out how to get and set the Update Full Geometry (from file) in the Update Base Geometry dialog and then pass in my own path. 

This opens it with no issues,  but avoiding any dialogs is ideal.

//Get the Action Manager	var actMgr = MainWindow.getActionMgr();	//Find the Full Base Geometry action	var oAction = actMgr.findAction("DzUpdateGeometryAction");	if (!oAction)		{			print("Didn't find the action: " +	oAction.name)			break;		}	if (oAction)		{			oAction.trigger();		}

 

Thank you to anyone that helps :D

Comments

  • See http://docs.daz3d.com/doku.php/public/software/dazstudio/4/change_log_4_21_0_5#4_20_1_68 , in particular (I think)

    • The “Update Base Geometry…” action (DzUpdateGeometryAction) can now be triggered from script with a settings Object (const QVariantMap& if calling from C++), via DzAction::triggerWithSettings(), to control its operation

      • If a RunSilent property is true the “Update Base Geometry” dialog is not displayed - the “Update Vertex Positions (from current shape)” option is the default choice

      • If an additional UpdateVertexPositions Boolean property is true, the “Update Vertex Positions (from current shape)” option is discretely chosen

        • If an additional Filename String property is not empty (provides the full path of a file to import), the “Update Vertex Positions (from file)” option is discretely chosen

      • If an additional UpdateFullGeometry Boolean property is true and an additional Filename String property is not empty (provides the full path of a file to import), the “Update Full Geometry (from file)” option is discretely chosen

      • An additional Importer Object property can be used to provide importer options

  • Thank you for pointing that out to me. I just can't seem to figure out how that would be implemented. I've looked at some of the examples and I am going crosseyed lol No matter what I try the farthest I can get is loading the action. Ive even tried var Settings = new DzSettings(); Settings.setBoolValue( "UpdateFullGeometry", true ); and the dialog loads but the default is still checked.

  • umblefuglyumblefugly Posts: 53
    edited October 2023

    Thank you, i'll have a look at that. My entire script is already about 150 lines of code. It's almost done, just some things have been stumping me lol

    Yeah, I think this is beyond me I guess. What's confusing is why this code works flawlessly for exporting with options, yet a similar setup doesn't work for the original question.

    (function(){		//No Dlg *.bj Export	var objExpPath = 'D:/objExp.obj';	var showOpt = false;	var objExp = App.getExportMgr().findExporterByClassName("DzObjExporter");		if(objExp)		{			// exSettings			var exSettings = new DzFileIOSettings();			exSettings.setBoolValue( "SelectedOnly", true );			exSettings.setStringValue( "Preset", "DAZ Studio (1 unit = 1cm)");			exSettings.setBoolValue( "WriteVT", true );			exSettings.setBoolValue( "WriteG", true );			exSettings.setBoolValue( "GroupGeom", true );			exSettings.setBoolValue( "GroupSurfaces", false );			exSettings.setBoolValue( "GroupSingle", false );			exSettings.setBoolValue( "WriteUsemtl", true );			exSettings.setBoolValue( "WriteMtllib", true );			exSettings.setIntValue( "FloatPrecision", 6 );			exSettings.setIntValue( "RunSilent", (showOpt ? 0 : 1));				objExp.writeFile(objExpPath, exSettings);		}		print("File exported to: " + objExpPath)	})();

     

    Post edited by umblefugly on
  • I am told this is because the objects (in the scripting sense) are different - one is a base Object , the other a DzFileIOSettings object.

  • I guess I just don't get it, im a visual person so I guess it isn't clicking and I'm afraid I'll probably abandon this. C# and Python are so much easier to do things in.  Appreciate the help anyhow Richard.

  • I was merely the relay - this is an area I have not had occasion to explore much myself.

  • OmnifluxOmniflux Posts: 377

    I think your confusion comes from a settings object not being a DzSettings object.

    Here is an example of how to do this

    (function(sFilename){	function updateGeometry(sFilename, bUpdateFullGeometry, oImporterSettings) {		var oAction = MainWindow.getActionMgr().findAction("DzUpdateGeometryAction");		if (oAction) {			var oSettings = {				"Filename" : sFilename,				"UpdateVertexPositions" : !bUpdateFullGeometry,				"UpdateFullGeometry" : bUpdateFullGeometry,				"Importer" : oImporterSettings,				"RunSilent" : true			};			oAction.triggerWithSettings(oSettings);		}	}	var oImporter = App.getImportMgr().findImporterByClassName("DzObjImporter");	if (oImporter) {		var oSettings = {//			"Preset" : "DAZ Studio (1 unit = 1cm)",//			"LatAxis" : "X",//			"VertAxis" : "Y",//			"DepthAxis" : "Z",//			"InvertLat" : false,//			"InvertVert" : false,//			"InvertDepth" : false,//			"Scale" : 243.84,//			"IncludeVT" : true,//			"IncludeF" : true,//			"IncludeL" : true,//			"IncludeG" : true,//			"IncludeUsemtl" : true,//			"IncludeMtllib" : true,//			"AutoAdapt" : false,			"RunSilent" : true		};		updateGeometry(sFilename, true, oSettings);		oImporter.deleteLater();	}})("D:/MyUpdatedObject.obj");

    Forum code blocks are broken, so quote this comment and then you can copy it out of the "Leave a Comment" editor.

  • Ahhhh! Thank you for that Omniflux and also thank you, Richard. Reading the changes and looking at how Omnifreaker implemented it makes more sense now.

  • So, I think I found a bug when using Update Base Mesh(Updating the mesh from the file)

    If the object selected was only imported and not rigged etc (a fresh object) I can update the base mesh multiple times with no issue.

    If the object selected is rigged etc (an object from the content dir..anything that is a mesh) I can update the base mesh once. The second time it will cause Daz Studio to CTD.

    I did this manually to verify that it wasn't my script causing it.

    If I run my script on an item in the content library( Once loaded into the scene of course) it works once, then gives an error after the second time.

    Heres some log output from running my script:

    // First Run updating the object in the scene
    2023-11-02 16:01:34.753 [DEBUG] :: Executing Script...
    2023-11-02 16:01:36.102 [DEBUG] :: Working...
    2023-11-02 16:01:36.104 [INFO] :: Exporting File...
    2023-11-02 16:01:36.201 [INFO] :: Saving Geometry...
    2023-11-02 16:01:36.305 [INFO] :: File exported in: 200.566 ms
    2023-11-02 16:01:36.305 [INFO] :: Exported file: C:\Users\USERNAME\AppData\Roaming\dsTemp\temp.obj
    2023-11-02 16:01:36.307 [DEBUG] :: Sending...
    2023-11-02 16:01:36.308 [DEBUG] :: Time Created: 20:01:36.251
    2023-11-02 16:01:36.308 [DEBUG] :: Waiting for Update...
    2023-11-02 16:01:42.269 [DEBUG] :: Updating...
    2023-11-02 16:01:42.269 [DEBUG] :: Time Modified: 20:01:40.104
    2023-11-02 16:01:42.345 [INFO] :: Reading: temp.obj
    2023-11-02 16:01:42.462 [INFO] :: Reading: temp.mtl
    2023-11-02 16:01:42.496 [INFO] :: Imported Wavefront Object: temp.obj
    2023-11-02 16:01:42.498 [DEBUG] :: Importing...
    2023-11-02 16:01:42.502 [DEBUG] :: Result: 
    2023-11-02 16:01:42.502 [DEBUG] :: Script executed in 7 secs 748 msecs.

    // Second Run updating the same object in the scene
    2023-11-02 16:01:48.922 [DEBUG] :: Executing Script...
    2023-11-02 16:01:50.181 [DEBUG] :: Working...
    2023-11-02 16:01:50.183 [INFO] :: Exporting File...
    2023-11-02 16:01:50.280 [INFO] :: Saving Geometry...
    2023-11-02 16:01:50.381 [INFO] :: File exported in: 198.721 ms
    2023-11-02 16:01:50.381 [INFO] :: Exported file: C:\Users\USERNAME\AppData\Roaming\dsTemp\temp.obj
    2023-11-02 16:01:50.384 [DEBUG] :: Sending...
    2023-11-02 16:01:50.384 [DEBUG] :: Time Created: 20:01:50.331
    2023-11-02 16:01:50.384 [DEBUG] :: Waiting for Update...
    2023-11-02 16:01:58.935 [DEBUG] :: Updating...
    2023-11-02 16:01:58.935 [DEBUG] :: Time Modified: 20:01:57.103
    2023-11-02 16:01:58.995 [INFO] :: Reading: temp.obj
    2023-11-02 16:01:59.098 [INFO] :: Reading: temp.mtl
    2023-11-02 16:01:59.132 [INFO] :: Imported Wavefront Object: temp.obj
    2023-11-02 16:01:59.134 [WARNING] :: D:\DAZDevel\Hudson\HUDSON_HOME\jobs\NB_Studio_Trunk\workspace\src\sdksource\general\dzscript.cpp(1189): Unhandled error while executing script.
    2023-11-02 16:01:59.134 [WARNING] :: QScriptEngine::popContext() doesn't match with pushContext()
    2023-11-02 16:01:59.135 [DEBUG] :: Result: 
    2023-11-02 16:01:59.135 [DEBUG] :: Script executed in 10 secs 211 msecs.

  • OmnifluxOmniflux Posts: 377

    I cannot reproduce with the script I posted above. Can you share yours?

  • umblefuglyumblefugly Posts: 53
    edited November 2023

    You can do it manually without a script.

    1. Load the G9 Base Shirt

    2. Set Resolution to Base

    3. Export as obj

    With the G9 Base Shirt selected in Daz Studio, Edit/Geometry/Update Base Geometry. Select Update Full Geometry (from file), load the file you just exported.

    Set your settings and let DS do its thing.

    Repeat that process once again and DS will crash to the desktop. No errors were written in the log.

    It only does it on files that were loaded from your library.

    Performing those actions on a file that was only imported (obj) works as expected.

    Interestingly, it crashes on the Gen 9 Base Clothing, but not others. Weird.

    Post edited by umblefugly on
  • OmnifluxOmniflux Posts: 377

    I can reproduce this (thanks for instruction to set resolution to base).

    Did you submit a ticket for this?

  • I have not yet. Maybe later today after house chores :)

  • Just an update, this question can be marked as solved. Thanks guys!

Sign In or Register to comment.