I am new to Ruby and Sketchup API.
I am searching how to import and apply a transformation to a PNG image.
I want to automate the same behaviour than when you use import a PNG from the file menu, set the origin and set the width of the image, but automatically with the API.
I did experiments the model.import:
model = Sketchup.active_model
status = model.import(“/private/tmp/background.jpg”, false)
The image is imported, but stick to the mouse pointer and I have still to click and put the scale from mouse.
How could I also set the origin and width from the API only ?
As a bonus, I would like to download the png from a URL and not anymore from a file.png.
In my opinion, I believe it is best if you become familiar with Ruby before you can apply the additions that the SketchUp API adds to the Ruby environment.
Try giving a valid URL for the path argument, to your remote file.
But be aware that some files types (with regard to certain operations) are edition or platform dependant (ie, Pro only, or Mac only.) Ref: https://help.sketchup.com/en/article/3000153
In the API images are imported wrapped within a special component subclass.
This class has methods for setting it’s transformation, height, width, origin, etc.
I wouldn’t necessarily agree on this point. You always need to start somewhere and it can just as well be making plugins/scripts for SketchUp as anything else. Having a practical goal can be very motivating when learning something new.
This is my opinion, I’ve stated it manys times. There is nothing that will ever make me feel any different.
Again and again, over and over I see newbies struggle needlessly, when they’d not do so if they had done like I, and read the “PickAxe” book cover to cover before even attempting any SketchUp programming.