Jump to content
Developer Wiki and Function Reference Links ×

Script to create a new “red” plug in symbol from selected


Recommended Posts

Hi!

 

I would like to make a script that creates a new “red” plug in symbol ufrom the selected plug in object.  My hope is to automate and collect some of the non-styled plug in objects (light lighting devices) at the end of a show, to re-use in the future. 
 

I can find an examples and commands for symbols, but I’m struggling to get started with plug in objects.  
 

If I can get a nudge in the right direction, it would be a huge help.  

Link to comment

A "Red" plugin is just a symbol that contains a single Plugin Object.  When you insert that symbol, rather than inserting it as a symbol, it inserts it and then ungroups (or equivalent) so that the PIO is what appears in the drawing.

 

SetObjectVariableBoolean(FSymDef,127,True); 

 

Will set the First Symbol Definition in the resource browser to be a "Red" symbol. But I have not figured out a good way to actually get the name of the symbol to change colors. The best I have found is to look at the resources in the file from a different file. Or edit the Edit the symbol Definition and just click OK.

 

Change the FSymDef to whatever code you need to identify your PIO converted to a symbol.

 

HTH

  • Like 1
Link to comment

Okay, so super rough script hammered out that will do what you want.  The script will prompt you to name the new symbol, and if the symbol name is valid and the first selected object of the active layer is a PIO, it will create a "red" symbol version of it in its current rotation.  Let me know if you would rather reset the rotation to 0 and I'll tell you what to change.  It should work with 2D, 3D, and hybrid PIOs.

 

Let me know if you have any questions or if anything breaks.

 

PROCEDURE SavePluginToRedSymbol;

{*	Stores selected PIO object as "red" Symbol
	Developed by: Jesse Cogswell
	Date: 7/9/2024
	Revisions:
*}

CONST

	kPIO = 86;
	kInsertAsGroup = 127;
	kScreenPlane = 1160;

VAR

	symHd,pioHd,tempHd:HANDLE;
	symName:STRING;
	nameCheck,BSB:BOOLEAN;
	loc,rot:POINT3D;

BEGIN
	nameCheck:=FALSE;
	symName:='';
	
	IF(GetTypeN(FSActLayer) = kPIO) THEN pioHd:=FSActLayer;
	
	WHILE(NOT nameCheck) DO
		BEGIN
			symName:=StrDialog('Enter Symbol Name','');
			
			IF(GetObject(symName) = NIL) THEN nameCheck:=TRUE
			ELSE
				BEGIN
					AlrtDialog('That name is in use, please enter a new one');
					nameCheck:=FALSE;
				END;
		END;
	
	IF((nameCheck) & (pioHd <> NIL)) THEN
		BEGIN
			BeginSym(symName);
				Locus(0,0);
				tempHd:=LNewObj;
			EndSym;
			
			symHd:=GetObject(symName);
			
			pioHd:=CreateDuplicateObject(pioHd,NIL);
			IF(GetEntityMatrix(pioHd,loc.x,loc.y,loc.z,rot.x,rot.y,rot.z)) THEN BSB:=SetEntityMatrix(pioHd,0,0,0,rot.x,rot.y,rot.z);
			
			IF(SetParent(pioHd,symHd)) THEN DelObject(tempHd);
			SetObjectVariableBoolean(pioHd,kScreenPlane,TRUE);
			
			SetObjectVariableBoolean(symHd,kInsertAsGroup,TRUE);
			IF(UpdateThumbnailPreview(symHd)) THEN SysBeep;
		END;
END;

Run(SavePluginToRedSymbol);

 

  • Like 1
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...