[@dxli and @sand1024] mslide action need help making img

Next Topic
 
classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[@dxli and @sand1024] mslide action need help making img

emanuel
This post was updated on .
During my first attempts to use mslide (create a slide from a drawing), I noticed a potential bug.

When creating a pixmap from the drawing,
regardless of whether I use "Export as Image" or mslide, a line isn't drawn at all.

I made a video and have attached the DXF file:
simplescreenrecorder-2025-04-18_21.mp4

bla.dxf

white is ignored

Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
I'm using a src similar to "Export as image,"
but I don't need the image of the entire drawing, just the section currently displayed and its scale. (viewport)

How can I set this up?
I need your help again!

source:
https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/actions/file/lc_actionfileexportslide.cpp#L136
Reply | Threaded
Open this post in threaded view
|

Re: [@dxli and @sand1024] mslide action need help making img

sand1024
In reply to this post by emanuel
well, it's not clear whether the line is clipped or whether it's just a black one on black background.

Try the following:
1) export with "white" background
2) try to export drawing not to image file, yet to svg (it's also supported as export format).

And then check whether the line is present or not.
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
In reply to this post by emanuel
Hm.. so you'd like to store to image only the area visible on the screen?

Well, that might be though - and depends on how you'd like to generate that image.

If this is standard generation (as it's currently is) - well, I suppose soon I'll add export of viewport. I've changed a little export to image (not committed to master yet) and noted that it exporting only visible area will be good addition.

But if you need to generate the image in some specific way (I suspect, say, via slide generation library) - it will require own entities rendering flow (similar to current rendering of the drawing), plus taking into consideration current viewport (offset & zoom factor) and current UCS.

So what specifically you're going to achieve?

Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
Hm... wait a little sorry - didn't check your link to the action before writing my previous comment.

Well, as I've suspected - you'd like to render the entities from that are visible in viewport to slide.

In general, right, it will be similar to rendering. However, I really don't think that the implementation currently included into your action is a right direction.

If I'm correct, you just try to render the document's entities into pixmap using standard rendering pipeline.

And after that - it seems that you try to vectorize that pixmap and detect lines based on pixmap content.

Is it is so?

Honestly, I really doubt that vectorization will bring reliable results, especially taking into consideration different zoom scales and possible content of the drawing. Yet probably I'm wrong.

Slide as I remember is also very basic vector format, yet by it's nature if I'm correct it's not portable (between machines) and is used mostly by AutoCAD only.

What for would you like to generate it? I can imagine adding support for reading Slide files, but as for generation... SVG will work much better nowadays, I suppose.

P.S - regarding your question - you should not try to create fresh new viewport like
   LC_GraphicViewport viewport = LC_GraphicViewport();.

The viewport controls zoom, offsets and borders for drawing window. So, you need:

a) either try to reuse the same viewport that is used by Graphic View that renders on the screen,

or

b)
create the copy of ViewPort and ensure that it will hold exactly the same internal state as viewport that is used for the screen rendering.





Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
>>Regarding the line phenomenon:
I've been playing around a bit. ByLayer seems to be ignored.
But it's even stranger...
In order for the changed attribute to actually be reflected when I change the color of the line, I have to completely close LC, even after saving. Restart, and then the line is created on pixmaps.
memory effect

>>MSLIDE
Yes, exactly, I create vectors from the pixels.
I'm writing an Acad V2 slide, which can also handle filled polygons,
but I don't yet have an algorithm that filters out rectangles based on size.
But it only works with vectors, so the file is a bit larger if the drawing contains solid fills.

Of course, I'm also making the slide for Lisp compatibility.

Everything in Lisp has that built in: AutoCAD, BricsCAD, ProgSoft, DraftSight, etc.
They don't have anything else in regular Lisp.

I've made everything a bit more modern in Lisp (Clojure 2014), but it's fully backwards compatible with AutoLisp.
I've already incorporated SVG, images, and text rendering into the Lisp GUI (only in LibreCAD).

I've put off programming Slide for ages.
But it does have its advantages (zoomable, small) and is a change from my eternal projects "entmake/entmod" and "ssget" (selecting/filtering/make/mod entity, ).

Here's the current video:
mslide-action.mp4
I can use the entire command for console_dxftosld, which is available as a tool.
For example, you can create <<Block Selection Slideshows>> with slides in the Script GUI. The scripter needs entire block drawings for that.
With AutoCAD, it's just possible to create a layout and then run the "mslide" command in the layout.
Here's the original description of the command:
https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-4AD7EF13-2B81-453B-BB80-9E2BBE7ED2DB

This screenshot sectioning feature is invaluable for scripters, especially for previewing details from the plan.
That's what I mainly need it for.

Thanks in advance: I'll try tip a/b

Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
>In order for the changed attribute to actually be reflected when I change the color of the line, I have to completely close LC, even after saving. Restart, and then the line is created on pixmaps.
memory effect

Well, potentially that might be... that depends on how the attribute change is applied. For example, any editing of the entity attributes or properties of the entity creates a COPY of that entity (and the original one is also stored for undo purposes).

So it might be that you save one instance, modify it - and while your script holds the reference to the source, actually the drawing renders modified version (or something like this).

Probably there is some other reason - yet it requires more detailed debugging to be sure.

>I've already incorporated SVG, images, and text rendering into the Lisp GUI (only in LibreCAD).
Yes, your intent is clear, yet I supposed that Slide is quite a legacy format nowadays to generate it...
As for sliders... hm... would not it be simpler just to do normal rendering instead of slides generation?
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
The generation is relatively simple, the result is good and is displayed in a smaller scale in the GUI.
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
again this strange memory effect:

The Slideview function also shows this strange memory effect, similar to changing the line attribute. If I open different slides, they are all displayed. Even if I create a new one with mslide. However, if I overwrite a slide that is already displayed with mslide and then immediately display it with vslide, I get a copy of the old slide displayed, which has actually been overwritten. If I now just close the document, create a new one, and then display the slide again, it displays the correct one. Even if I close LC completely and restart it, I can see that the slide was correctly overwritten. I could not find any memory errors in my source. I have also tried explicitly setting the LC_SLIDE class to null. Once displayed, the slide is essentially married to the active document.
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
emanuel wrote
I could not find any memory errors in my source. I have also tried explicitly setting the LC_SLIDE class to null. Once displayed, the slide is essentially married to the active document.
Hm... where is it in your code?
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
In reply to this post by emanuel
hm... you've moved them to some other branch after merge? It seems there are no files by your links...
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
Yes, I had to. Your commit was the hardest part!

I'm having fun embedding my patch for now. I've been working on it for hours because 90% of the interfaces no longer work.

Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

dxli
The API is likely getting more tweaks still.

Some long time technical dets have to be handled, sooner the better.

Ideally, we design the API, tweak the design, and go ahead with implementation.

In reality, the design was only getting in shape after the code works.

emanuel wrote
Yes, I had to. Your commit was the hardest part!

I'm having fun embedding my patch for now. I've been working on it for hours because 90% of the interfaces no longer work.

Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
In reply to this post by emanuel
I'm back in the race...

I reinstalled everything because GitHub couldn't apply the patch anymore.
I then made the stupid mistake of asking the new GitHub Pilot for help...
It turned out there was an AI called ctp40 behind it.
The tip from that thing destroyed everything.
So back to the real backup "Brain." If that's broken, I don't need anything anymore anyway,

@sand1024: after reinstalling everything, I tested the strange save effect again:

1) Changing the line color now works. The color is now also changed on the screen without reopening the file.

2) Creating images and slides from the drawing:
Error: "ByLayer" and "black/white" are not rendered.

3) Overwriting and reopening slides still shows me a copy of the first slide on the screen.
The slide is created correctly, though.
please have a look at:
https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/actions/file/lc_actionfileexportslide.h
https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/actions/file/lc_actionfileexportslide.cpp

https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/actions/file/lc_actionfileviewslide.h
https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/actions/file/lc_actionfileviewslide.cpp

https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/lib/engine/overlays/slide/lc_slide.h
https://github.com/emanuel4you/LibreCAD/blob/developer/librecad/src/lib/engine/overlays/slide/lc_slide.cpp


@dxli: I was able to activate all the workflows now. But I still need help.
I always have to include the "librecad.py" file in the AppImg or the Install.exe.
I know how to do this for Linux, but how do I include it in the Windows and Mac build script? Please take a look at my scripts:
https://github.com/LibreCAD/LibreCAD/compare/master...emanuel4you:LibreCAD:developer
https://github.com/emanuel4you/LibreCAD/tree/developer/CI
https://github.com/emanuel4you/LibreCAD/actions

What also puzzles me: How does the Windows build know that it needs to install swig.exe and Python?
I only included it for Linux and Mac? But it builds.
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

dxli
I got a similar trouble with "Spline through Points", and did a quick fix here:

Spline through Points

The direct cause appears that RS_Entity::setPenToActive() is noop, if it's not a child of an RS_Document.

I'm not sure this pen issue is actually relevant for your case.

emanuel wrote
2) Creating images and slides from the drawing:
Error: "ByLayer" and "black/white" are not rendered.
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

sand1024
@dxli

I really suspect that this is related to adding impl class that contains pen to the RS_Entity.

    struct Impl;
    const std::unique_ptr<Impl> m_pImpl;

Actually - this issue https://github.com/LibreCAD/LibreCAD/issues/2098

As pen instance was not copied in that change - I've also seen interesting effects, where changing layer's pen leads to changing of the pen of entity.

However, I supposed I've fixed this in my last PR...

in more general sense - I'm not sure that original historical setPenToActive() is a good design (actually it's a bad one).

It adds lots of over-coupling dependencies between entity, graphics, layer and layer list.. so in the future, it's reasonable to remove that method from the entity and move to the code that creates entity (like RS_Creation, actions or so).
Reply | Threaded
Open this post in threaded view
|

Re: [Export Image] BUG? - first attempts to use mslide

emanuel
In reply to this post by dxli
@dxli: I think the error lies in the RS_Render.
simplescreenrecorder-2025-04-20_23.mp4
Please watch the video and test the attached file. The X is one line "byLayer" and the other "White/Black."
bla.dxf
12