Jump to content
Developer Wiki and Function Reference Links ×

Closing active document


Recommended Posts

Hello,

I have a marionette that does some stuff, then saves the current document under a different name (self made node with SaveActiveDocument; works) and then tries to close it (also self made node, but doesn't work).

The only way to close the active document I found is by using DoMenuTextByName with

vs.DoMenuTextByName('Close',0)

 

The first problem I have is that it just doesn't run if it is part of a complex node network (that exists as a node object and gets saved as a symbol and erases itself (for that I use a node created by DomC, the code is below)). -> I think it might be a problem inside a network converted to a node object.

If I just run the save and close nodes as a two node network, then VWX crashes. This also happens when changing the save operation to save the file without a name change via DoMenuTextByName with save. The save node itself works without crashing for both variants though.

The second problem is, that if I separate the close node and run it manually via right click, then a menu pops up to ask if I want to save active changes, even if the file was saved right before running the node.

I have a placeholder input port so that the node can be connected to a network.

 

Is there another way to do this or am I doing something wrong?

Also, can I automatically have the file saved (auto select first option from pop up) after running the close command? That would be an acceptable alternative, as it ultimately does the same as saving and then closing. (Still would need to figure out how to run it as part of the complex network then though)

 

 

 

Code for symbol creation:

#DomC v001

@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
	By = 'DomC';import datetime; now = datetime.datetime.now(); y80f5 = now.year;m80f5 = now.month; d80f5 = now.day; h180f5 = now.hour; mi180f5 = now.minute; s180f5 = now.second; ms180f5 = now.microsecond; h280f5 = h180f5-12 if h180f5 >=13 else h180f5; VersionChange1 = str(y80f5)+' '+str(m80f5)+' '+str(d80f5); VersionChange2 = str(y80f5)+'-'+str(m80f5)+'-'+str(d80f5)+'-'+str(h280f5)+'-'+str(mi180f5); 
	TextStatic = Marionette.OIPControl( By +' v'+VersionChange2, Marionette.WidgetType.TextStatic, "")
	this = Marionette.Node( "Create Symbol" )
	this.SetDescription( 'Creates a new Symbol' )
	
	h_obj =  Marionette.PortIn(vs.Handle(0))
	h_obj.SetDescription( "symbol content (one object) if empty, an empty 3D (3D Locus) symbol will be created" )
	
	s_name = Marionette.PortIn('Symbol-1')
	s_name.SetDescription( "the symbol name" )
	
	s_sym = Marionette.PortOut()
	s_sym.SetDescription( "the result symbol name" )
	
	h_sym = Marionette.PortOut()
	h_sym.SetDescription( "handle to the newly created symbol" )


def RunNode(self):
	obj = self.Params.h_obj.value
	name = self.Params.s_name.value 
	vs.BeginSym(name)
	vs.Locus3D(0,0,0)
	h = vs.LNewObj()
	vs.EndSym()
	
	vs.Marionette_DisposeObj(h)
	
	h_sym = vs.GetObject(name)
		
	vs.SetParent(obj, h_sym)
	vs.ResetObject(obj)
	vs.ResetObject(h_sym)
	
	self.Params.s_sym.value = name
	self.Params.h_sym.value = h_sym

 

Edited by LichtLukas
Added explanation
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...