Jayme McColgan Posted December 4, 2023 Share Posted December 4, 2023 hello everyone. I'm building a plugin that will allow me to export labels from a drawing to a pdf. I recently switched from just using symbols and linked text fields to a small point object plugin which gives me more flexibility with text and such. when I export the pdf using the code below none of the point object plugins show up in the exported file BUT if I navigate to the sheet layer that the code made they are there. this workflow worked fine when using just symbols. my initial thought is that since it is spawning the PIO within the same script that's exporting the PDF maybe they don't visually exist yet? Here's the code. I stripped out some other code so it might look weird... if vs.AcquireExportPDFSettingsAndLocation(True): vs.OpenPDFDocument(f"{filename}") width = 8.5*vs.GetUnits()[3] height = 11*vs.GetUnits()[3] sheet_num = f"PL-{num}" name = f"Printable Labels - {num}" curlayer = vs.CreateLayer(sheet_num, 2) ### Create Sheet Layer vs.SetObjectVariableString(curlayer, 159, name) ### Set Sheet Layer Name vs.SetDrawingRect(width, height) ### Set Sheet Layer Size last = vs.CreateCustomObjectN('Fixture Label Object',x,y,0, False) vs.SetRField(last,'Fixture Label Object','symbolname', final_label) vs.ExportPDFPages(f"PL-{i+1}") vs.ClosePDFDocument() Quote Link to comment
Pat Stanford Posted December 4, 2023 Share Posted December 4, 2023 I think you are correct. The objects are not instantiated until the script run completes. Try RedrawAll before the Export and see if that fixes it. If not, then add all the other potential things like ResetObject, Reset Bounding Box, Redraw after each object and see if any of them help. Quote Link to comment
Jayme McColgan Posted December 5, 2023 Author Share Posted December 5, 2023 thanks pat. sadly none of those did it for me. unless someone else can think of a way to refresh the page, I'm probably gonna have to break these into 2 separate plugins. Quote Link to comment
Jayme McColgan Posted December 5, 2023 Author Share Posted December 5, 2023 @Pat Stanford if I do split them up into 2 separate processes, is it possible to trigger another menu command plugin at the end of the first plugin script and will it refresh before running the next menu command sctipt? Quote Link to comment
Pat Stanford Posted December 6, 2023 Share Posted December 6, 2023 I don't know of a way using VS to call another VS. I assume that Python probably has the same problem. But maybe you could use a "wrapper" around both scripts to call them in sequence? I will think about it. Quote Link to comment
Jesse Cogswell Posted December 6, 2023 Share Posted December 6, 2023 For menu commands, you can call another VS menu command by using DoMenuTextByName('Your Command Name',0); I assume it would be the same with Python. In this instance, I think the way I would go about doing this is to make the PDF export the main script and call the label creation script with vs.DoMenuTextByName. This should allow the label creation script to fully complete before exporting the PDF. If you put the label creation script into the Category Don't Put In Workspace, it won't populate in the Workspace Editor, so you can make sure someone doesn't try to use that script by mistake. 1 Quote Link to comment
Pat Stanford Posted December 6, 2023 Share Posted December 6, 2023 Please report back if you find something that works. We all need the information. Quote Link to comment
Jayme McColgan Posted December 11, 2023 Author Share Posted December 11, 2023 yeah, this is gonna take a minute to figure out. I've moved the whole process to a 2 step which fixed my original issue. (I was probably gonna do that the whole time) BUT... now I'm back in the boat because I have a dialog to preview/edit the label and things like "vs.UpdateSymbolDisplayControl()" and such aren't working because I'm creating a temp symbol with a vs.CreateCustomObjectN() inside the temp symbol creating. I'll update if I achieve anything. Quote Link to comment
Jayme McColgan Posted December 19, 2023 Author Share Posted December 19, 2023 On 12/6/2023 at 2:53 PM, Pat Stanford said: Please report back if you find something that works. We all need the information. UPDATE: I got this to work for me by turning on "Reset on Move" and "Reset on Rotate" on the point object tool that I'm inserting with vs.CreateCustomObjectN() Quote Link to comment
Jayme McColgan Posted December 27, 2023 Author Share Posted December 27, 2023 FALSE ALARM: this seems to only work the FIRST TIME after starting VW, It won't work any other time. is there something that would cause a menu command to work differently on its first run vs any other run? Quote Link to comment
Recommended Posts
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.