Pat Stanford Posted February 19, 2023 Share Posted February 19, 2023 I know I can do the tests myself, but I am hoping for some guidance before I start beating my head against the wall. I have an object that I need to convert to a bitmap. So far I have tested putting that object into an existing symbol definition and using CreateImgFromSymbolN and it works great for what I am doing. What is not working so great is trying to create the symbol, put the object into it and then make the bitmap. It appears that I am caught in the "objects don't exist until the script completes" trap. Redraw, RedrawAll, ResetObject don't seem to make any difference. So could I create the Symbol in one of the object events, then add my object(s) to it and run the CreateImg in a different event? Or are Event Enable Objects also a single "script" and objects don't exist until the entire object regenerates? Is there a way to force a second regeneration of the object that could help? @Sam Jones@MullinRJ@JBenghiat Help?? Quote Link to comment
MullinRJ Posted February 19, 2023 Share Posted February 19, 2023 Hi Pat, I think I've done something similar recently, where I needed a Bitmap in a Symbol, to show in a WS. I was able to create the object, convert it to a Bitmap, then move the Bitmap into a newly created symbol – all in one script. No Event-Enabled anything. Is that close to what you are looking to do? If so, I'll dig up the code for you. Raymond Quote Link to comment
Pat Stanford Posted February 19, 2023 Author Share Posted February 19, 2023 Yes, that sounds good, but kind of the opposite of what I am trying to do. I am trying to put things into a symbol so I can make a bitmap from the symbol. But I had no success on creating a new symbol. When I started with a base symbol that already existed I could move the object into the symbol and make the bitmap. When I create a new symbol in the script I get a nil handle back from the CreateImgFromSymbolN function. Quote Link to comment
MullinRJ Posted February 19, 2023 Share Posted February 19, 2023 (edited) Hi Pat, I found my code { build object in a symbol } BeginSym(kImgSym); PushAttrs; { create object here } PopAttrs; EndSym; { object symbol } { make image from symbol } H := CreateImgFromSymbolN(kImgSym, 692, 792, 0, 0, 2, 1); { 692 & 792 are pixels of image} DelObject(GetObject(kImgSym)); { delete object symbol } { recreate the same symbol, now with dummy locus... } BeginSym(kImgSym); { create empty symbol } Locus(0, 0); { dummy locus } EndSym; { ...then with image of the object } B := SetParent(H, LNewObj); { move image into symbol } GetBBox(H, P1.x, P1.y, P2.x, P2.y); { P1 & P2 are vectors } P1 := -(P1 + P2) / 2; hMove(H, P1.x, P1.y); { center image in symbol } DelObject(FIn3D(LNewObj)); { remove dummy locus } ResetBBox(LNewObj); { reset symbol's BBox - very necessary } I use the same symbol name for the object and the image. After I create the bitmap, I delete the symbol then recreate it with a Locus as a place holder. Then I move the image into the symbol and remove the Locus. If you already have the object before this point, you should be able to move it into the symbol instead of create it there, and proceed as outlined above. If this works for you, meet me in Albuquerque and you can buy me a beer. 😉 Raymond Edited February 19, 2023 by MullinRJ finish writing Quote Link to comment
Pat Stanford Posted February 19, 2023 Author Share Posted February 19, 2023 Thank you Raymond. I will compare to my code and try again. I thought that was what I was doing, but if it worked for you I must have been trying something different.🤷♂️ Quote Link to comment
MullinRJ Posted February 19, 2023 Share Posted February 19, 2023 FWIW, my code runs in a Tool (.vst) and it's not Event Enabled. Quote Link to comment
Pat Stanford Posted February 19, 2023 Author Share Posted February 19, 2023 Thank you Raymond. I got it working. Don't know exactly what I was doing wrong before. Quote Link to comment
MullinRJ Posted February 19, 2023 Share Posted February 19, 2023 1 hour ago, Pat Stanford said: Thank you Raymond. I got it working. Don't know exactly what I was doing wrong before. Glad to hear. It's probably not worth the effort to figure that out. Quote Link to comment
Elite Exhibits Posted February 21, 2023 Share Posted February 21, 2023 Pat My question would be: How do you use this script ? Peter Quote Link to comment
Pat Stanford Posted February 21, 2023 Author Share Posted February 21, 2023 If I can get it to work as I think it can, there might be a way to be able to split worksheets that are too long into multiple columns. Quote Link to comment
Recommended Posts
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.