Jump to content

vs.CreateCustomObjectN() not showing in PDF Export


Recommended Posts

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()
    

 

Link to comment

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.

  • Like 1
Link to comment

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. 

Link to comment
  • 2 weeks later...
  • 2 weeks later...

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...