X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=bs6twa5jo+hr5n6CbmCXvwmb5GtOFlM3AHU76pxcKXk=; b=p4YKMMn2AEzm/Pgj91Ac3/KlNZ3rdusmpMVdqsxdAIJlNcuiGezwatruzzlCAk/kn7 RPnsp7DCytlQdSzvSH0oLij76AKLwMszRncplJQtGsz1HjfwVNUjeoUYMGaYPI9wNUAo fT2nCpSJDTdUMJaL4daHeYbjLptOIG7tkJWNVRAJNEwktoMBTvJASF0AzIiVoeAC5iXU grNXpYGjss2/aeJf5+N1SDZMj6yQjZ6orEkCzyqYxpOgSml9ign/SfkgeP+lkU5rRiiv E1Qa9UEUBG3gUisjzqDBIzTH7CU5s4PgC1EmKvF0aZJMhsjd81IL0Gi8b9LZdOSwyweW Ns8A== X-Received: by 10.112.210.137 with SMTP id mu9mr26809165lbc.95.1437398276887; Mon, 20 Jul 2015 06:17:56 -0700 (PDT) Date: Mon, 20 Jul 2015 16:17:54 +0300 From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] The new to do Message-ID: <20150720131753.GA19305@localhost.localdomain> Mail-Followup-To: geda-user AT delorie DOT com References: <0A5D410F-D1EF-4FC6-AF0F-BB13218B1615 AT icloud DOT com> <20150714084906 DOT GC14371 AT localhost DOT localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="OgqxwSJOaUobr8KG" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=utf-8 Content-Disposition: inline On Mon, Jul 20, 2015 at 02:10:55AM +0200, Kai-Martin Knaak wrote: > Vladimir Zhbanov (vzhbanov AT gmail DOT com) > [via geda-user AT delorie DOT com] wrote: > > > What a first scripting example would you like to see in the > > scripting how to? > > > Do a custom PDF print of the pcb layout: > page one: top layer with refdes > page two: top layer with values > page three: bottom layer with refdes > page four: bottom layer with values > all pages: black silk, black outline, pads and pins in dark gray and > tracks in light gray. Rescale the layout until it fits an A4 paper. > > Ok, this may be a bit over the top for a first example. It is what I > actually need, though. So I whipped up a bash script which calls the > pcb printing hid with action commands to change sides and switch from > refdes to value. I had to patch pcb to not exit immediately. It > assumes that non-interactive hids should never use these commands and > exits preemptively. Unfortunately, my patch which replaced this > deliberate exit with a warning did not get accepted by the devs. So I > habitually apply this patch locally. > > Back to a first example for useful scripting. How about multi-copy: > Copy/paste the current selection multiple times translated by an > amount given by the user. For bonus points also rotate the selection > by an angle with each paste action. Rereading your post after I wrote the script for gschem, I start to suspect you've meant PCB here, haven't you? Anyway, the script for gschem is attached. Comments and example usage are inside, and an only comment here: there are many rotation strategies and I've applied one I think is more appropriate for this case. Cheers, Vladimir --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="move-and-rotate.scm" ; Scripting example by vzh per request of Kai-Martin Knaak :-) ; Use at your own risk. ; The main procedure here is ; multiple-copy-move-and-rotate-selection which can be abbreviated ; as mcmars. ; Usage: ; launch gschem so it can use this script, e.g. ; gschem -s move-and-rotate.scm ; select objects in gschem, then hit ':' (semicolon) and type ; (mcmars '(1000 . 500) 90 10) ; hit ; Enjoy! (use-modules (gschem selection)) ; align coords by ALIGN (define (ceiling-coords vector align) (cons (* (ceiling-quotient (car vector) align) align) (* (ceiling-quotient (cdr vector) align) align) )) ; Get minimum X and minimum Y of two pairs of coords (define (min-coords coord1 coord2) (let ((x (min (car coord1) (car coord2))) (y (min (cdr coord1) (cdr coord2)))) ; return value (cons x y))) ; Copy, move and rotate current selection. The selected objects ; are first copied, then translated by VECTOR and finally rotated ; by ANGLE about center which is calculated as rounded by 100 ; lower left coordinate of all objects in selection. ; If no objects are selected, opens gschem message dialog with ; warning. ; Returns the copied objects. (define (copy-move-and-rotate-selection vector angle) (let ((objects (page-selection (active-page)))) (if (null? objects) (gschem-msg "Select something first!") ; else (let* ((copied-objects (map copy-object objects)) (translated-objects (apply translate-objects! vector copied-objects)) (bounds (apply object-bounds translated-objects)) (rotation-center (ceiling-coords (min-coords (car bounds) (cdr bounds)) 100)) (rotated-objects (apply rotate-objects! rotation-center angle translated-objects))) (apply page-append! (active-page) rotated-objects) rotated-objects) ))) ; Multiply VECTOR which must be a pair by NUMBER (define (multiply-vector-by vector number) (cons (* number (car vector)) (* number (cdr vector)))) ; Copy, move and rotate current selection NUMBER times. Applies ; the copy-move-and-rotate-selection procedure multiple times ; increasing every time vector and angle by given values of VECTOR ; and ANGLE. ; If no objects are selected, opens gschem message dialog with ; warning. ; Returns value is unspecified. (define (multiple-copy-move-and-rotate-selection vector angle num) (if (null? (page-selection (active-page))) (gschem-msg "Select something first!") ; else (do ((i num (1- i))) ((= i 0)) (copy-move-and-rotate-selection (multiply-vector-by vector i) (* angle i))) )) ; Abbreviated name for the multiple-copy-move-and-rotate-selection ; procedure (define mcmars multiple-copy-move-and-rotate-selection) --OgqxwSJOaUobr8KG--