Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Background: Consider the following graphics directive.

     Dashing[{Small, Small}], 
     RGBColor[0, 0, 1]]]

In a Manipulate I want to interactively change Thickness, Dashing, Opacity and Color of the edges of Polygons in a pattern. So, for each of them I will have to create a control. The EdgeForm is stored in Excel =as is=. So I will need to extract the values which will become the starting values for the controls out of the EdgeForm above, i.e.:

    {Small, Small}, 
    RBGColor [0,0,1]

for the four controls respectively.

My strategy was to ToString[EdgeForm[ ...everything ] and then do string manipulations on them but that turned out to become a lot of ( messy, still not working ) code. Considering this is Mathematica ( I thought that ) there must be a simple way to get the values out of that EdgeForm.

Question: How to change the EdgeForm above to {Large, {Small, Small}, 0.1, RBGColor [0,0,1] }. Needless to say that the values change per pattern, i.e. Tiny, Large, etc.

share|improve this question
You can use list manipulation functions on any expression, not merely Lists. You can do anything with that EdgeForm that you can do with a List, e.g. take a Part of it, Replace something inside, etc. It seems to me that you asked this question because you were not aware of this. – Szabolcs Apr 20 '12 at 15:19
Yes..., the paradigm issue. I will try a few things. – nilo de roock Apr 20 '12 at 15:24
OMG. That was in fact the answer. It's good that I asked anyway. Thanks. – nilo de roock Apr 20 '12 at 15:26
up vote 5 down vote accepted

As @Szabolcs points out in the comments, you can always use Part or Replace regardless what head your expression has. I personally prefer ReplaceAll in cases such as this because I find it easier to tell what I intended with my code when I dig it up months or years later.

ef = 
  EdgeForm[Directive[Thickness[Large], Dashing[{Small, Small}], 
    Opacity[0.1`], RGBColor[0, 0, 1]]];

ef /. 
 EdgeForm[Directive[Thickness[t_], Dashing[d_], Opacity[o_], 
    col_]] :> {t, d, o, col}

==> {Large, {Small, Small}, 0.1, RGBColor[0, 0, 1]}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.