Thank you very much for the tips. Philip
----- Original Message ----- From: Hans Breuer <[email protected]> Date: Sunday, March 15, 2009 5:44 pm Subject: Re: Changing objects layer through Python To: discussions about usage and development of dia <[email protected]> > At 15.03.2009 16:42, Philip Cavaco wrote: > > That did the trick. Now I am stuck on a way to update the image > with all > > changes I made. The script completely connects all "Standard - > Ellipse"> within the currently selection. The connections do not > appear unless I > > manually move each Ellipse in the diagram. I have tried using > > update_extents, add_update_all, and update_connections but none > seem to > > do what I need. > > > Indeed. Even the usual > > if display : > display.add_update_all() > > did no help but it gave a hint. Your arcs did not where they were > (i.e. > drawn at the wrong place). See below for the solution. > > Hans > > > Here is the script > > > > # This function completely connects the given group of "Standard - > Ellipse" > > # objects with "Standard - Arc" objects with open circles (ending > 9).> # > > > > import dia > > > > EXCITE_CONN = 8 > > INHIB_CONN = 9 > > CONN_TYPE = INHIB_CONN > > > > def complete_connect(data,flags): > > """ > > > > Arguments: > > - `data`: > > - `flags`: > > """ > > d = dia.active_display().diagram > > layer = d.data.active_layer > > grp = d.get_sorted_selected() > > connType = dia.get_object_type("Standard - Arc") > > for o in grp: > > if o.type.name == 'Standard - Ellipse': > > for target in grp: > > if target.type.name == 'Standard - Ellipse' and > not o == > > target: > > #Connect to all other nodes except itself > > temp_conn, h1, h2 = connType.create(0,0) > > #temp_conn.properties['end_arrow'].value.type = > > CONN_TYPE > > h1.connect(o.connections[8]) > > h2.connect(target.connections[8]) > > layer.add_object(temp_conn, 0) > # second looping to effectively catch all connections > for o in grp: > d.update_connections(o) > > > #Apply changes to display > > d.update_extents() > > -------- Hans "at" Breuer "dot" Org ----------- > Tell me what you need, and I'll tell you how to > get along without it. -- Dilbert > _______________________________________________ > dia-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/dia-list > FAQ at http://live.gnome.org/Dia/Faq > Main page at http://live.gnome.org/Dia > > _______________________________________________ dia-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://live.gnome.org/Dia/Faq Main page at http://live.gnome.org/Dia
