Jump to content
Forum Maintenance - Thursday, June 21st 2018 - 4PM EST Read more... ×
DomC

PDF Export, ResetObject

Recommended Posts

Hi 

I have issues to reset a PIO before I export PDF. I tried:

 

1. Using vs.AcquireExportPDFSettingsAndLocation(True) and vs.OpenPDFDocument(bfbfab68-bd4e-11e6-a4a6-cec0c932ce01) and vs.ExportPDFPages('bfbfab68-bd4e-11e6-a4a6-cec0c932ce01')

2. Force PIO Regeneration by insert an Object in the PIO and delete that object

3. Creating a Reset Command and call this with DoMenuText and the call PDF Export

 

I think PDF Export by script is supressing any reset of pios. So the Idea was, to search a function by force reset the objects. I think an attempt could by 

Any Ideas?

 

 

 

criteria="L = 'Lay-1'"
objs = []
def BuildObjList(h):
	vs.SetFillBack(h, (4567,4123,78694))
	vs.ResetObject(h)
	

vs.ForEachObject(BuildObjList, criteria)
vs.DoMenuTextByName('Export PDF',0)

 

Dialog Script.vwx

Share this post


Link to post

The problem with resetting the plugin is that the code has to complete before it actually gets reset. It does not happen immediately when it is called. What I do is set a hidden Boolean parameter to true on the first reset event. When the pio goes through the second reset event, it will encountered the true value and execute the code in question and then I will set the parameter back to false.

  • Like 1

Share this post


Link to post

@Miguel Barrera

I am not sure if I understand and I am think you mean playing with ObjectVariableBoolean  1167

I will try soon if I have time. 

 

Thank you for the hint! 

Share this post


Link to post

In your code above, the reset to each object in the loop will happen only after the DoMenuTextByName call or the last line of code.

Share this post


Link to post

Dom,

   I think you can only get your approach to work if you split your code in two. Your first script will contain everything up to, and including, your RESET calls. When your first script ends, VW will then reset all of the objects you marked to be reset. Your second script can then execute the DMTBN( 'Export PDF') call. It's a very sequential process, but your "Export" call cannot begin until all of the PIOs get reset, and they will not reset until after your script ends. Therefore you need two scripts that you will will launch sequentially. Not entirely elegant, but easily accomplished.

 

HTH,

Raymond

Share this post


Link to post
Posted (edited)

Hi Mullin thanks for comment

Yes thats the pragmatically solution which is running at the Moment -two separate scrips.

 

 

Just tested Miguel's hint, and it works. Really Great!

 

criteria="L = 'Lay-1'"
objs = []

def BuildObjList(h):	
	vs.SetFillBack(h, (4567,4123,78694))
	vs.SetObjectVariableBoolean(h,1167,True)
	objs.append(h)
	
vs.ForEachObject(BuildObjList, criteria)

for h in objs:
	vs.ResetObject(h)
	vs.SetObjectVariableBoolean(h,1167,False)	

vs.DoMenuTextByName('Export PDF',0)

Or even shorter and simpler:

criteria="L = 'Lay-1'"

def DoIt(h):	
	vs.SetFillBack(h, (4567,4123,78694))
	vs.SetObjectVariableBoolean(h,1167,True)
	vs.ResetObject(h)
	vs.SetObjectVariableBoolean(h,1167,False)	

vs.DoMenuTextByName('Export PDF',0)

 

Edited by DomC

Share this post


Link to post

Well, that's the first time I've seen that ObjVar used, though a quick search shows it appeared in VW 2014's documentation. I learn something new every day, even when I don't want to  ;-)  However, it does say "for use with SDK objects ONLY". Have you tried with VS or Python PIOs? If SDK Only, then it's true, the VS engine can only handle one task at a time without interruption. I can live with that. 

 

Thanks, both, for the info.

 

Raymond

Share this post


Link to post

The Script resets a ComputerWorks Multi-Stamp SDK PIO. For just PDF export I never would create a script. The main part is updating all stamp symbols. The real script

does the following:

 

1. Importing (updating PIO graphic) symbols 

2. Create a time and date value (thanks to python)

3. Update PIOs (The pio is linked to a record format which is importing data from an external source by another script)

 

I love vectorscript and marionette. But I am always sceptical if a script is really is necessary. This is a border case for sure.

 

#28.03.2018
#Alte Planköpfe mit neuen ersetzen
vs.DSelectAll()


listID, numItems = vs.BuildResourceListN(16, 'S:\\Vorlagen\\VectorWorks\\18_Offerte\\Vorgabe_Offerte_2018.vwx')
sym_names = []


def callback():
	pass


for i in range(numItems):
	res_name = vs.GetNameFromResourceList(listID, i)
	sym_names.append(res_name)
	if res_name == 'SSSPK Küche A4':
		 vs.ImportResToCurFileN(listID, i, callback)
	if res_name == 'SSSPK Küche A4q':
		 vs.ImportResToCurFileN(listID, i, callback)
	if res_name == 'SSSPK Küche A4h':
		 vs.ImportResToCurFileN(listID, i, callback)	 	 
	if res_name == 'SSSPK Küche Installation A4':
		 vs.ImportResToCurFileN(listID, i, callback)	 	 
	if res_name == 'SSSPK Küche Installation A3':
		 vs.ImportResToCurFileN(listID, i, callback)	 	 
	

#Datum und Zeit vor PDF aktualiesiern Ja/Nein

import datetime
now = datetime.datetime.now()

jahr = now.year; monat = '%02i' % now.month; tag = '%02i' % now.day; stunde = '%02i' % now.hour; minute = '%02i' % now.minute

Datum = str(tag)+'.'+str(monat)+'.'+str(jahr)
Zeit = str(stunde)+':'+str(minute)

#Datum = 'DatumTest'
#Zeit = 'ZeitTest'

objs = []
def AktualisiereDat():
	plankopf="INSYMBOL & INOBJECT & INVIEWPORT & (R IN ['Daten_ERP'])"

	def PlankopfFelder(h):
		vs.SetRField (h, 'Daten_ERP','114_Datum', Datum)
		vs.SetRField (h, 'Daten_ERP','115_Zeit', Zeit)
		objs.append(h)
		vs.SetObjectVariableBoolean(h,1167,True)
		vs.ResetObject(h)
		vs.SetObjectVariableBoolean(h,1167,False)
	vs.ForEachObject(PlankopfFelder, plankopf)

auswahl = vs.YNDialog('Zeit, Datum aktualisieren?')

if auswahl:
	AktualisiereDat()

vs.DoMenuTextByName('Export PDF',0)

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×