[SOLVED] Select only bitmap image

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

[SOLVED] Select only bitmap image

Post by sinase » Thu Mar 18, 2021 6:13 pm

Hi,

I have a bitmap image impoted on my panel in qcad and i have lines and other figures too. There is any way to select only my bitmap? I would like that to select and delete only the image automatically by script.

Many thanks.
Last edited by sinase on Tue Mar 23, 2021 10:06 am, edited 1 time in total.

User avatar
ryancousins
Premier Member
Posts: 367
Joined: Thu Mar 19, 2020 3:47 am
Location: Michigan, USA

Re: Select only bitmap image

Post by ryancousins » Thu Mar 18, 2021 7:33 pm

It sounds like maybe you're trying to do this via script? If so I don't know how to do that. But otherwise, you can bring up the selection filter View>Selection Filter and filter by entity type of "Image". Then you would click on one of the selection options, such as "replace current selection".

You could also put the image on it's own layer by itself and limit your selection that way.

Sorry if I wasted your time with the non-script way. :lol:
Attachments
selections.png
selections.png (4.93 KiB) Viewed 7399 times

sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Re: Select only bitmap image

Post by sinase » Mon Mar 22, 2021 10:31 am

Thank you for your help ryancousins.

I didn't know about the selection filter option. I would like to work with this option by script way, i don't know if is that possible (in qcad documentation i have not found nothing about this).

I anybody have an idea, thank you.
Regards.

sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Re: Select only bitmap image

Post by sinase » Mon Mar 22, 2021 10:40 am

You gave me an idea, when i import the image, i could insert this image with a new layer and by this way i can to hide this image or not if i need it.

Thank you.
Regards.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Select only bitmap image

Post by andrew » Mon Mar 22, 2021 10:41 am

Given an array of entity IDs, you can easily filter out those of a given entity type:

Code: Select all

var ids = doc.queryAllEntities();
for (var i=0; i<ids.length; i++) {
        var e = doc.queryObject(ids[i]);

        if (e.getType()===RS.EntityImage) {
            // entity is an image
        }
        else {
            // entity is not an image
        }
}

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Select only bitmap image

Post by CVH » Mon Mar 22, 2021 11:03 am

Hi... In the same line ...

Code: Select all

var di = this.getDocumentInterface();
var doc = di.getDocument();
var ids = queryAllEntities(false, true , RS.EntityImage)    // NOTundone, DOallBlocks, Filter on type

// The amount of images found:
var imgCount = ids.length;

// The first or only image id found:
var imgID = ids[0];

// The image itself:
var imageEntity = doc.queryEntity(imgID);

// Only valid is it exists:
if (isNull(imageEntity)){
    return undefined;    // Failed: Not a valid entity
}

// An easy way to delete ojects is using simple_create.js
// Include simple.js for that at the top     include("scripts/simple.js");
deleteObject(imageEntity);
But too slow ... :wink:
Regards,
CVH

sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Re: Select only bitmap image

Post by sinase » Tue Mar 23, 2021 10:06 am

Hi, finally i took the option to create a new layer and to insert the image in that layer. In this way, i can hide and show the image when i want.

Thank you.
Regards.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”