Menu

#470 sameprop plugin doesn't copy the "by layer" placeholder (flag)

2.0.4
open-fixed
Rallaz
sameprop (1)
5
2015-07-02
2014-06-14
No

In my particular use case / scenario, it would help me to copy the color, line width and line style from one object (manually rectified) to a set of other objects. I understand that the plugin called "same properties" does exactly that. My additional requirement is, that I want to set all the objects to get their decoration style "by layer". And that does not work. The "same properties" menu command just copies the current actual color, line width and line style from the source object - even if the source object acquires them "by layer" :-)

I haven't downloaded the full source tree, but using the github's HTTP interface I've been able to track this down to the following files:

in LibreCAD / plugins / sameprop / sameprop.cpp :

the plugin's code is actually pretty lean and clean.
I can see the following lines for instance:

col = data.value(DPI::COLOR);
for (int i = 0;...;...)
  moddata.insert(DPI::COLOR, col );

That's pretty obvious.
It seems that the attributes are passed indirectly, picked by an enum...

in LibreCAD / librecad / src / plugins / document_interface.h :

that's where Namespace DPI is inhabited by some enums.
And apart from the definition of DPI::COLOR, DPI::LWIDTH and DPI::LTYPE,
I've also discovered two further interesting enums (and their respective enum members):

enum LineWidth {
  ...
  WidthByLayer = -1, /**< Line width defined by layer not entity. */
}


enum LineType {
  ...
  LineByLayer = -1,     /**< Line type defined by layer not entity */
}

Interestingly, no enum for "Color by Layer".
Makes me wonder if the color value passed is possibly an immediate RGB(A) value encoded in some data type that has no room for a "color by layer" special option...

in LibreCAD / librecad / src / lib / engine / rs.h :

I can see a definition of

class RS2 {
   ...
   enum Flags {
      ...
      /** Entity attribute (e.g. color) is defined by layer. */
      FlagByLayer = 1<<2,
   }
}

which is further used throughout other source files, such as
librecad/src/lib/engine/rs_color.cpp.

Now... document_interface.h appears to declare a public API for plugins.
The rs.h on the other hand, looks like an internal header (not accessible
to the plugins). Not sure if there is a chance to get the "color by layer"
flag copied from object to object within a plugin. The DPI namespace
does not contain an enum for any flags...

Interestingly, the current source code of sameprops.cpp actually fails to copy the line width and style as well, despite the fact that the data type appears to have the "by layer" special values embedded in the relevant enum :-)

This is over my head... it would be nice to have this corrected, but I'm not very desperate to get this solved anytime soon. In the drawing snippet that I'm trying to sketch, I'll just have to work around it (use hard-coded colors).

Maybe a few words about my scenario: I'm trying to import a map into LibreCAD via DXF, using only free tools. I've discovered that I can get a "printout" of the map into PDF or PS in vectors, with aspect ratio maintained :-) I can read that into Inkscape, edit and sanitize the vectors a bit, and export them into DXF. The DXF (R14 level) exported from Inkscape has some known shortcomings, but it maintains
layers for instance - pretty good. The trouble is that, given what Inkscape is, it does not attach a line color and style to a layer, but instead to individual line objects. So that when I open the DXF in LibreCAD (which can assign a line style to a layer), the specific styles assigned to individual line objects override the "per layer" style... which is a pain to edit whenever I want to fiddle with the overall look of my sketch, balance the layers visually based on relative importance etc...

I guess noone has complained about this before me... I'm probably quite a corner case maniac :-)
Normal people, who create things from scratch in LibreCAD, are just satisfied with the current behavior of "same properties", because whatever line you draw in LibreCAD, it has the "by layer" attributes set by default.

The same goal could actually be achieved, if the "Modify->Properties" tool actually worked on sets of selected objects, rather than a single object that you have to click (any pre-existing multi-selection is ignored). That's what I tried first, really...

There's another interesting behavior: if I export filled shapes from Inkscape into DXF, LibreCAD crashes when reading the file :-) I'm aware that the DXF created by Inkscape is probably not perfect, but OTOH LibreCAD probably doesn't validate the file very much, if it crashes on reading it :-) It takes a while before the crash comes - as if LibreCAD got into an endless recursive loop and finally ran out of stack space or something... I can provide a sample DXF file if you ask me (as part of a separate bug report maybe).

Thanks and kudos for the great job that you're doing on LibreCAD :-)

Frank

Discussion

  • Frank Rysanek

    Frank Rysanek - 2014-06-15

    Apologies, I'm a noob to LibreCAD.
    The right command for what I'm trying to achieve is "edit entity attributes", AKA Modify -> Attributes.
    Sorry about my yesterday's intrusion. Close the ticket please...

     
  • Frank Rysanek

    Frank Rysanek - 2014-06-15

    ...actually, not exactly. "edit entity attributes" does work on a selected set, and does allow you to select color and other attributes "by layer", but that again simply copies the values. The placeholder "by layer" does not get copied to entities in the selected set... But it's less painful to use than the "same properties" plugin.

     
  • Rallaz

    Rallaz - 2015-07-02

    Added a patch solving plugin issue with color, linewidth and linetype in plugins.
    Now ByLayer & ByBlock are handled correctly.

    About the other issues, please open a new bug report for each to avoid noise and things lost

     
  • Rallaz

    Rallaz - 2015-07-02
    • status: unread --> open-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB