kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #09761
Re: Script access to pcb plot
Hi Lorenzo,
I've been playing with the PLOT CONTROLLER, and it works great, I added
this to let SVG & PDF output in colors, but for some reason, the colors
stay in the default color that kicad uses for a layer, I'm on an ongoing
investigation about this.
MACSRV:kicad ajo$ bzr diff
=== modified file 'pcbnew/pcbplot.cpp'
--- pcbnew/pcbplot.cpp 2013-03-20 04:46:32 +0000
+++ pcbnew/pcbplot.cpp 2013-03-23 14:15:09 +0000
@@ -388,3 +388,19 @@
return true;
}/*}}}*/
+void PLOT_CONTROLLER::SetColorMode( bool aColorMode )
+{
+ if( !m_plotter )
+ return;
+
+ m_plotter->SetColorMode( aColorMode );
+}
+
+bool PLOT_CONTROLLER::GetColorMode()
+{
+ if( !m_plotter )
+ return false;
+
+ return m_plotter->GetColorMode();
+}
+
=== modified file 'pcbnew/plotcontroller.h'
--- pcbnew/plotcontroller.h 2012-08-29 16:59:50 +0000
+++ pcbnew/plotcontroller.h 2013-03-23 13:49:16 +0000
@@ -26,6 +26,8 @@
bool OpenPlotfile( const wxString &aSuffix, PlotFormat aFormat,
const wxString &aSheetDesc );
bool PlotLayer( int layer );
+ void SetColorMode( bool aColorMode );
+ bool GetColorMode();
private:
/// Option bank
yet uncommited,
The thing is , for some reason, any color I set is ignored, and default
color is used. My current script is something like this:
# Test for batch plot scripting capabilities
# Acquire stuff from pcbnew and build a plot controller from the
# current board
from pcbnew import *
pctl =
PLOT_CONTROLLER(LoadBoard("/Users/ajo/Documents/work/rbou/pobocomm/pcb/mainboard.kicad_pcb"))
# Now we can use it to do many kinds of plot... the first thing to
# do is access the plot options inside it
popt = pctl.AccessPlotOpts()
# Then we set all the plotfile level options. Everything has some
# default (most of these are sane AFAIK)
# The output directory is relative to the board file
popt.SetOutputDirectory("/tmp/fabs2")
popt.SetPlotFrameRef(False)
popt.SetLineWidth(FromMM(0.35))
popt.SetAutoScale(False)
popt.SetScale(1)
popt.SetDrillMarksType(PCB_PLOT_PARAMS.NO_DRILL_SHAPE)
popt.SetMirror(False)
popt.SetSubtractMaskFromSilk(True)
popt.SetPlotReference(True)
popt.SetPlotValue(False)
popt.SetPlotOtherText(True)
popt.SetPlotInvisibleText(False)
pctl.OpenPlotfile("Layout", PLOT_FORMAT_PDF, "General layout")
pctl.SetColorMode(True)
pctl.PlotLayer(DRAW_N)
popt.SetColor(BLUE)
pctl.PlotLayer(EDGE_N)
pctl.ClosePlot()
exit()
2012/8/20 Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxx>
> OK, done the deed, it seems to work. There is one thing I'm still
> undecided for, mostly for the user's convenience of use.
>
> I attached a test script which showcases most of the features.
>
> As you can see with the BOARD you can create a PLOT_CONTROLLER. The plot
> controller contains the plot setting object (HAS-A relationship).
>
> So, in the script, you configure with the popt object and then do stuff
> using the pctl object containing it.
>
> However I see that maybe the user maybe would like to set options directly
> in
> the controller object; there is a good design decision (for me) in
> separating the interface but users usually don't get OO design nuances
> (also they use the office ribbon which comes right from the deepest pit
> of hell).
>
> This could be done very easily, actually, simply using public
> inheritance (use of C++ inheritance for containment is...
> controversial). I don't like it but could be done.
>
> Any comment?
>
> --
> Lorenzo Marcantonio
> Logos Srl
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
>
--
Miguel Angel Ajo Pelayo
http://www.nbee.es
+34 636 52 25 69
skype: ajoajoajo
Follow ups
References