Submitted by iamfallen on Thu, 05/30/2013 - 08:59
Forums:
Is it possible to set a plot scale in a journal file? My thought of using a scaled plot layout didn't work as the journal recorder didn't record in the Plot Layout Dialog Box. I have tried searching net_ref.chm for "Plot Scale" but nothing I have found has been terribly helpful to me.
Thanks for your help.
re: 1/2 scale plot
Does it have to be exactly 1/2 scale?
I'd be tempted to just export a .pdf at full scale, open the pdf, hit 'print', pick my desired paper size and let the pdf reader program auto scale the plot down to fit...
My goal was to simplify and
My goal was to simplify and automate a long process that is currently done by an ancient GRIP program. The GRIP has many options that are not needed for this level and requires many extra user inputs. Thanks to your help earlier, my script currently adds a volume note and several other pieces of information in the correct position independent of sheet size, plots at full scale, and then removes the development information back off of the drawing. I just need it to be plotted half scale now as the engineers don't need(or want) a full scale at this level. If I have to go out to open the pdf to "plot" then I am no longer saving any time in the process. I thought this would be easier, as the macro recording will record inside of the Plot layout window. Since Journal does not, I am lost in looking for the information to set these settings.
I did find this in searching the net_ref.chm though:
int UF_PLOT_add_job_to_plot_layout
(
tag_t drawing_sheet,
UF_PLOT_job_options_p_t job_options,
char * job_name,
UF_PLOT_units_t units,
double origin [ 2 ] ,
UF_PLOT_rotation_t rotation,
double scale,
UF_PLOT_extents_p_t extents
)
Is this what I need to add the currently viewed sheet to the plot layout at scale? The page wasn't very helpful about format.
Re: Journal to plot half scale?
This is what I have tried so far. I am new to this so please help me understand where I am going wrong.
Dim drawing_sheet1 As Drawings.DrawingSheet In displayPart.DrawingSheets
Sub AddJobToPlotLayout (
drawing_sheet As Tag = drawing_sheet1.Name,
ByRef job_options As UFPlot.JobOptions(),
job_name As String = Checkplot,
units As UFPlot.Units.Millimeters,
origin As Double = (0,0),
rotation As UFPlot.Rotation.Rotation0,
scale As Double = 0.5,
ByRef extents As UFPlot.Extents()
)
re: plot 1/2 scale
Here is a quick example, it only plots the 1st sheet of the display part. Before running it you will need to change the plotter name in the UFPlotSheet routine (and possibly the profile string as well).
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
Dim mySheet As Drawings.DrawingSheet = displayPart.DrawingSheets.ToArray(0)
UFPlotSheet(mySheet)
End Sub
Sub UFPlotSheet(ByVal dwgSheet As Drawings.DrawingSheet)
Dim myJobOptions As UFPlot.JobOptions
theUfSession.Plot.AskDefaultJobOptions(myJobOptions)
Dim jobOrigin() As Double = {0, 0, 0}
Dim jobExtents As UFPlot.Extents
Dim jobName As String
theUfSession.Plot.AskDefaultJobName(dwgSheet.Tag, jobName)
Dim jobBannerOptions As UFPlot.BannerOptions
theUfSession.Plot.AskDefaultBannerOptions(jobBannerOptions)
Dim jobUnits As UFPlot.Units
If displayPart.PartUnits = BasePart.Units.Inches Then
jobUnits = UFPlot.Units.Inches
Else
jobUnits = UFPlot.Units.Millimeters
End If
theUfSession.Plot.AddJobToPlotLayout(dwgSheet.Tag, myJobOptions, jobName, jobUnits, jobOrigin, UFPlot.Rotation.Rotation0, 0.5, jobExtents)
'$$$ change the plotter name and profile in the next line as necessary $$$", 1)
theUfSession.Plot.PrintPlotLayout(jobName, jobBannerOptions, "INNOVATION_PLOTTER", "
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
End Function
End Module
note on pdf file
Side note: if you were to pursue the pdf file option, you wouldn't have to "go out and open the pdf" as the journal could be coded to open it automatically after creation. With a bit more work, you might even be able to get it to print to a predefined printer/paper size, though I've never taken it that far...