[Ipe-discuss] IPE7: select all objects which contain a certain code in XML?

Zhengdao Wang zhengdao at iastate.edu
Wed Nov 23 18:22:29 CET 2011

What you wanted seems to be useful. I put together an ipelet as follows.

-----  BEGIN CUT
-- select.lua
-- select objects by string in XML

label = "Select object by XML string"

about = [[
Select object by XML string

function run(model)

  local d = ipeui.Dialog(model.ui:win(), "Get Selection String")
  d:add("pattern", "input", { syntax="xml" }, 1, 1)
  _G.addEditorField(d, "pattern")
  d:addButton("cancel", "&Cancel", "reject")
  d:addButton("ok", "&Ok", "accept")
  if pattern then d:set("pattern",pattern) end

  if not d:execute() then return end
  pattern = d:get("pattern")

  if not pattern or pattern == "" then return end

  local p=model:page()
  -- p:deselectAll() -- use this if want all deselected first
  for j = 1,#p do
    if string.find(xml, pattern) then
      p:setSelect(j, 1)
----- END CUT

-----Original Message-----
> From: elwood151 <elwood151 at web.de>
> Date: Wed, 23 Nov 2011 06:09:15 -0600
> To: "ipe-discuss at cs.uu.nl" <ipe-discuss at cs.uu.nl>
> Subject: [Ipe-discuss] IPE7: select all objects which contain a certain
>  code in XML?
> Is it possible in IPE7 to
> select all objects in the current page which contain a certain string (e. g.
> a color like
> stroke="0.188 0.49 0.949" )?
> Could that be done with an Ipelet?
> (I have imported graphs of functions from another application as PDF and I
> want to format them in a consistent way:
> example: all have normal dash style and pen, but different colors.
> To display them unambigously in greyscale, the blue line shall e. g. be
> dotted and the red one shall have a different dash style and pen, etc...
> Therefore, I have to e. g. select all blue curves and change their stroke,
> dash style and pen to something else.
> Selecting each one by hand is very time consuming and can cause errors, so
> the easiest way would be to select all of them by a certain unambigous
> criterion (in this case the color).
> I'm sure this could also be done by editing the xml file with search and
> replace, but I don't know enough programming to parse the xml, identify the
> lines belonging togehter for each "object" and then modifying them, if one
> of them matches a certain criterion).
> I don't know how much effort it would be to write an ipelet which parses all
> objects on a page an adds those to the selection which contain a certain
> string in their XML data.
> Can somebody help me?
> I'd happily make a donation for the helping person or for charity to
> appreciate the effort.
> Kind regards
> Martin
> --
> View this message in context: http://old.nabble.com/IPE7%3A-select-all-objects-which-contain-a-certain-code-in-XML--tp32873896p32873896.html
> Sent from the Ipe - General mailing list archive at Nabble.com.
> _______________________________________________
> Ipe-discuss mailing list
> Ipe-discuss at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/ipe-discuss

More information about the Ipe-discuss mailing list