Hi Asahi,<br><br>Thanks a lot for taking your time to review. Appreciate uploading the edited file. Helped me a lot. And the new script-runner  plugin is simply stunning.<br><br>Thank you<br>Vinayan<br><br><br><div class="gmail_quote">
On Wed, Mar 21, 2012 at 8:56 AM, ASAHI Kosuke <span dir="ltr">&lt;<a href="mailto:asahi@hcc.co.jp">asahi@hcc.co.jp</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Vinayan<br>
<br>
I can run your script on qgis 1.7.4,<br>
but I change few points adapt to script runner plugin(see following link).<br>
<br>
<a href="http://spatialgalaxy.net/2012/01/29/script-runner-a-plugin-to-run-python-scripts-in-qgis/" target="_blank">http://spatialgalaxy.net/2012/<u></u>01/29/script-runner-a-plugin-<u></u>to-run-python-scripts-in-qgis/</a><br>

<br>
Please run this script on script runner.<br>
 <a href="http://d.hatena.ne.jp/waigani/files/rotate.py?d=download" target="_blank">http://d.hatena.ne.jp/waigani/<u></u>files/rotate.py?d=download</a><br>
<br>
If you have crash again, I need more infomation (OS? version? etc..).<div><div></div><div class="h5"><br>
<br>
(2012/03/21 1:14), vinayan wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hi all,<br>
<br>
I just read about running python scrips from Qgis Console(article by<br>
Gary Sherman<br>
<a href="http://spatialgalaxy.net/2012/01/27/qgis-running-scripts-in-the-python-console/" target="_blank">http://spatialgalaxy.net/2012/<u></u>01/27/qgis-running-scripts-in-<u></u>the-python-console/</a>).<br>
I am trying rotate each point in a layer based on a center point. I<br>
managed some code by copying from the CadTools plugin(by Stefan<br>
Ziegler). Whenever i run this from qgis console, it crashes the<br>
application. Can somebody point me in the right direction? Please find<br>
the code below. I have to admit that i started python only yesterday.<br>
<br>
Note: I am not sure if this is the place to ask this. But i have been<br>
inspired by reading<br>
<br>
<br>
------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>------------<br>
#!/usr/bin/env Python<br>
&quot;&quot;&quot;Load all shapefiles in a given directory.<br>
This script (iteratefeature.py) runs from the QGIS Python console.<br>
 From the console, use:<br>
from iteratefeature import Looper<br>
ldr = Looper(qgis.utils.iface)<br>
ldr.LoopXY()<br>
<br>
&quot;&quot;&quot;<br>
from glob import glob<br>
from os import path<br>
from qgis.core import *<br>
import math<br>
<br>
class Looper:<br>
def __init__(self, iface):<br>
&quot;&quot;&quot;Initialize using the qgis.utils.iface<br>
object passed from the console.<br>
<br>
&quot;&quot;&quot;<br>
self.iface = iface<br>
<br>
<br>
def LoopXY(self):<br>
<br>
basePoint=QgsPoint(-121.<u></u>3140824, 38.63196648)<br>
rotAngle=45<br>
<br>
mc = self.iface.mapCanvas()<br>
layer = mc.layer(0)<br>
provider = layer.dataProvider()<br>
<br>
feat = QgsFeature()<br>
provider.select()<br>
<br>
<br>
while(provider.nextFeature(<u></u>feat)):<br>
#layer.startEditing()<br>
geometry = feat.geometry()<br>
geom1=rotate(geometry,<u></u>basePoint,rotAngle * math.pi / 180)<br>
layer.changeGeometry(<a href="http://feat.id" target="_blank">feat.id</a>()<u></u>, geom1)<br>
#feat.setGeometry(geom1)<br>
#print &quot;X Coord %d: &quot; %geometry.asPoint().x()<br>
#print &quot;Y Coord %d: &quot; %geometry.asPoint().y()<br>
layer.commitChanges()<br>
print &quot;updated %d: &quot; %<a href="http://feat.id" target="_blank">feat.id</a>()<br>
print<br>
<br>
# Rotate script<br>
def rotate(geometry, point, angle):<br>
<br>
if angle == 0 or angle == 2 * math.pi or angle == -2 * math.pi:<br>
return geom<br>
<br>
p0 = geometry.asPoint()<br>
p1 = QgsPoint(p0.x() - point.x(), p0.y() - point.y())<br>
p2 = rotatePoint(p1, angle)<br>
p3 = QgsPoint(point.x() + p2.x(), point.y() + p2.y())<br>
return QgsGeometry().fromPoint(p3)<br>
<br>
<br>
# Rotates a single point (centre 0/0).<br>
# (c) Stefan Ziegler<br>
def rotatePoint(point, angle):<br>
x = math.cos(angle)*point.x() - math.sin(angle)*point.y()<br>
y = math.sin(angle)*point.x() + math.cos(angle)*point.y()<br>
return QgsPoint(x, y)<br>
<br>
<br>
------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>----<br>
<br>
Regards<br>
Vinayan<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a><br>
</blockquote><font color="#888888">
<br>
<br>
-- <br>
ASAHI Kosuke<br>
<br>
</font></blockquote></div><br>