Jump to content
Developer Wiki and Function Reference Links ×

Vectorworks SDK 2025


Recommended Posts

We were using VWs 2021 to utilize SDK and connect to a web application through Vectorscripts. Now, we have moved to version 2025 and one urgent issue is coming up. Can somebody help.
We take a snapshot of drawing without text around it and it used to work fine in 2021 version. Now that we have moved to 2025, it is taking a screenshot of the drawing along with the text around.

Can somebody please help. I am not sure if commands has changed or what is happening.

I am using the following:

def ClipWhitespaceFromImage(self, inImageFilename):
        try:
            image=Image.open(inImageFilename)
            image.load()

            bg = Image.new(image.mode, image.size, image.getpixel((0,0)))
            diff = ImageChops.difference(image, bg)
            diff = ImageChops.add(diff, diff, 2.0, -100)
            bbox = diff.getbbox()
            if bbox:       
                new_image = image.crop(bbox)
                new_image.save(inImageFilename)
            logging.debug("Saved clipped image to " + inImageFilename)
        except:
            logging.debug("!!!Exception: In ClipWhitespaceFromImage: " + traceback.format_exc())

        return inImageFilename

 

    def MakeWhitePixelsNonOpaque(self, inImageFilename):
        try:
            start_color = (255, 255, 255, 255) # white
            new_color = (255, 255, 255, 0) # black
            img = Image.open(inImageFilename).convert("RGBA")

            shape_data = numpy.array(img)
            # Replace start color with new color
            shape_data[(shape_data == start_color).all(axis = -1)] = new_color
            # Convert back to image
            final_image = Image.fromarray(shape_data, mode='RGBA')
            final_image.save(inImageFilename, "PNG")
            logging.debug("Saved opacity image to " + inImageFilename)
        except:
            logging.debug("!!!Exception: In MakeWhitePixelsNonOpaque: " + traceback.format_exc())

        return inImageFilename

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...