Jump to content
Developer Wiki and Function Reference Links ×

Can I do this without (or with) an event enabled object?


Recommended Posts

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??

Link to comment

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

 

 

Link to comment

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.

Link to comment

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 by MullinRJ
finish writing
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...