Valentine Heart

Author:
Thomas Müller
Description:
Valentine Heart
LastUpdate:
2014-02-14
OperaVersion:
16R1
Tag:
Fun
Screenshot:
screenshot: heart.jpg

This script was written by Klaus. It will create a heart out of wire edges and then make it beat and spin in the modeller.

Description of Image

These are the coordinates of the heart: halfheart.txt (160 B, 5y ago)

heart.comi
/ Script for the Opera-3d Modeller
/
/  MakeHeart.comi
/  to create a polyline object by reading node (x,y) input from a text file
/
/  Notes:
/  A text file with node (x,y) data of the required profile is needed for this script.
/  
/
/  To run this script:
/  Open a Modeller window
/  Open a "Command File Editor" from the "Command Files" Menu
/  Open this file
/  "Run Current File" from the "Commands" menu
/
/
/ Test whether this script is actually running in the Modeller
/ ==============================================================
$IF PROGRAM NE 2
 $DIALOG ACTION=START TITLE='Warning!'
 $DISPLAYLINE 'This is a script for the Opera-3d Modeller.'
 $DISPLAYLINE 'It will not run in this program.' 
 $DISPLAYLINE ' '
 $DISPLAYLINE 'The script will now be stopped.'
 $DISPLAYLINE ' '
 $DISPLAYLINE 'Click any of the buttons.'
 $DISPLAYLINE ' '
 $DIALOG ACTION=STOP
 $ABORTCOMI
$END IF
/ ======================================
/
/ =========================================================
/ Make sure that the Modeller is "empty" before we start
/ =========================================================
$IF (BODIES+CONDUCTORS) NE 0
 $DIALOG ACTION=START TITLE='Warning!'
 $DISPLAYLINE 'An old model or parts of it are already present.'
 $DISPLAYLINE 'How do you want to proceed?'
 $DISPLAYLINE 'Pressing the OK button will "rewind the history" (clear everything) and carry on.'
 $DISPLAYLINE '"Cancel" will stop this script.'
 $DISPLAYLINE ' '
 $DIALOG ACTION=STOP
 UNDO STATE=ROOT | HISTORY STATES=0
$END IF
/ ======================================
/
/
$STRING datafile 'HalfHeart.txt'
$STRING bodyname 'Heart'
$CONSTANT #Z -1
/
$DIALOG START 'Polyline Text Input'
  $GROUPBOX START 'Input Data' Horizontal 1 
    $fileprompt datafile 'Text Input File'
    $prompt     bodyname 'Body name for the plate'
    $ask #z 'Location in z' HISTORY=yes EDIT=yes 
  $GROUPBOX STOP
$DIALOG ACTION=STOP
 
GUIOPTIONS OPTION=SET -CONSOLEVIEW CONSOLEBUFFER=20000 +PRINT3DCARD 
WINDOW AXES=NONE
/activation $breakerror to allow reading of arbitrary length datafile
$errorhandler no
 
/ Open the file and read lines of data
  $OPEN 1 '&datafile&' read
  $do #c 1 1e99
	$read 1 #x%int(#c) #y%int(#c)
	$breakerror
  $end do
$CLOSE 1
$ERRORHANDLER YES
 
$CONSTANT #np #c-1
 
/ Construct Wires
/ ===================
$do #i 1 #np-1
 
$constant #j #i+1
 
WIREEDGE Name='&bodyname&' X0=#x%int(#i) Y0=#y%int(#i) Z0=#z X1=#x%int(#j) Y1=#y%int(#j) Z1=#z EDGETYPE=STRAIGHT
 
$end do
 
/ Initialize View
/ ====================
THREED OPTION=SETVIEW SIZE=0
/
/ Copy to make other half
/ ======================================
PICK OPTION=ADD PROPERTY=Name LABEL=&bodyname& 
TRANSFORM OPTION=COPY KEEP=NO TYPE=REFLECT NU=1 NV=0 NW=0 COUNT=1
 
 
 
/ Cover the wireedges with a face
/ ====================================
PICK OPTION=ADD PROPERTY=Name LABEL=&bodyname& 
PICK OPTION=CHANGE TYPE=EDGE 
COVER NAME=&bodyname& UNIQUENAME=&bodyname&
/
/ Sweep into a Volume
/ =====================
PICK OPTION=ADD PROPERTY=Name LABEL=&bodyname& 
PICK OPTION=CHANGE TYPE=FACE 
SWEEP TWISTTYPE=NONE KEEP=NO TYPE=VECTOR REGULARISE=NO RIGID=NO DU=0 DV=0 DW=2 DRAFTTYPE=NONE 
/
/ Blend corners
/ =====================
PICK OPTION=TOGGLE TYPE=FACE UNIQUEBODYNAME='Heart' IDENTIFIER=BR.00039
PICK OPTION=TOGGLE TYPE=FACE UNIQUEBODYNAME='Heart' IDENTIFIER=BQ.00001
PICK OPTION=CHANGE TYPE=EDGE
BLEND  OPTION=BLEND RADIUS=.8
/
/ Colour
/ =====================
PICK OPTION=ADD PROPERTY=Name LABEL=&bodyname& 
PICK OPTION=CHANGE TYPE=CELL 
CELLDATA OPTION=MODIFY MATERIALLABEL='Heart' POTENTIAL=Total ELEMENTTYPE=Linear SIZE=1 NORMALTOL=20 ELEMSHAPEPREF=NONE
COLOUR OPTION=SET PROPERTY=MATERIAL LABEL=Heart RED=255 GREEN=0 BLUE=0    |/ i.e. red
/
MODEL CREATE
MESH SIZE=1 NORMALTOL=30 SURFACETOL=0.0 TOLERANCE=1.0E-06 TYPE=PREFERMOSAIC 
 
/ Animate
/ ======================
THREED OPTION=SETVIEW XORIGIN=0 YORIGIN=9 ZORIGIN=0 SIZE=9
 
$DO #LOOP 1 8 1
THREED SIZE=9+mod(#loop;2) FACETANGLE=10 PERSPECTIVE=YES LINECOLOUR=YES OPTION=SETVIEW
$PAUSE 1
$END DO
 
/
/ Spin
/ ======================
#a=roty
$DO #LOOP 0 360/5*10 5
$PAUSE 0.2
THREED ROTY=#a+#loop OPTION=SETVIEW 
$END DO
/ end of comi-file
fun/valentine_heart/start.txt · Last modified: 2014/11/12 12:47 by mueller
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0