Scott Ayers
09-07-2010, 07:19 PM
Hey Guys,
Using Coffee.
I know how to create dialogs and add attributes (sliders,check boxes, text,etc.) to them for menu plugins. But I can't figure out how to add attributes to tags for tag plug-ins.
I've looked through all of the SDK stuff. But I can't find any examples of how to add custom attributes to the tags themselves.
I think I have to use a BaseContainer in my Edit function. But without seeing an example I'm not really sure if that's right, or how exactly to do it.
Here's a very simple tag plugin example that just turns on the xray attribute:
const var PLUGIN_ID = 12121212; //Just For testing purposes<----DO NOT DIRSTIBUTE THIS ID# publicly!!!
var tagIcon;
class xrayTag : ExpressionPluginTag // the XrayTag's class
{
public:
xrayTag();
GetID();
MultipleAllowed();
DisplayAllowed();
GetIcon();
GetHelpText();
UseMenu();
GetName();
Edit();
Execute(doc, op);
}
xrayTag::xrayTag()
{
// Call parent constructor
super();
}
xrayTag::GetID() { return PLUGIN_ID; }
xrayTag::MultipleAllowed() { return TRUE; }
xrayTag::DisplayAllowed() { return TRUE; }
xrayTag::GetIcon() { return tagIcon; }
xrayTag::GetHelpText() { return "Xray object example"; } // Bubble help text. If option is turned on in the preferences
xrayTag::UseMenu() { return TRUE; }
xrayTag::GetName() { return "XRay object"; } //The text displayed for the tag in the OM/ and lower right corner of UI
xrayTag::Edit()
{
var dlg = TextDialog("Drag the object upwards to see the result", DLG_OK);
}
xrayTag::Execute(doc, op)
{
var doc=GetActiveDocument();
if (!doc) return FALSE;
var obj = GetActiveObject(doc);
var pos = obj->GetPosition();
if(pos.y > 100)
{
obj#ID_BASEOBJECT_XRAY=TRUE;
}
else
{
obj#ID_BASEOBJECT_XRAY=FALSE;
}
EventAdd();
return;
}
/////////
// Main
main()
{
// Get the icon
var fn = GeGetRootFilename();
fn->RemoveLast();
fn->AddLast("xrayicon.tif");
tagIcon = new(BaseBitmap,1,1);
tagIcon->Load(fn);
// Registers the tag
Register(xrayTag);
}
Does anyone have a small example of doing this?
Feel free to edit the code I posted and insert an attribute, or two, for the tag. If that's more convenient.
-ScottA
Using Coffee.
I know how to create dialogs and add attributes (sliders,check boxes, text,etc.) to them for menu plugins. But I can't figure out how to add attributes to tags for tag plug-ins.
I've looked through all of the SDK stuff. But I can't find any examples of how to add custom attributes to the tags themselves.
I think I have to use a BaseContainer in my Edit function. But without seeing an example I'm not really sure if that's right, or how exactly to do it.
Here's a very simple tag plugin example that just turns on the xray attribute:
const var PLUGIN_ID = 12121212; //Just For testing purposes<----DO NOT DIRSTIBUTE THIS ID# publicly!!!
var tagIcon;
class xrayTag : ExpressionPluginTag // the XrayTag's class
{
public:
xrayTag();
GetID();
MultipleAllowed();
DisplayAllowed();
GetIcon();
GetHelpText();
UseMenu();
GetName();
Edit();
Execute(doc, op);
}
xrayTag::xrayTag()
{
// Call parent constructor
super();
}
xrayTag::GetID() { return PLUGIN_ID; }
xrayTag::MultipleAllowed() { return TRUE; }
xrayTag::DisplayAllowed() { return TRUE; }
xrayTag::GetIcon() { return tagIcon; }
xrayTag::GetHelpText() { return "Xray object example"; } // Bubble help text. If option is turned on in the preferences
xrayTag::UseMenu() { return TRUE; }
xrayTag::GetName() { return "XRay object"; } //The text displayed for the tag in the OM/ and lower right corner of UI
xrayTag::Edit()
{
var dlg = TextDialog("Drag the object upwards to see the result", DLG_OK);
}
xrayTag::Execute(doc, op)
{
var doc=GetActiveDocument();
if (!doc) return FALSE;
var obj = GetActiveObject(doc);
var pos = obj->GetPosition();
if(pos.y > 100)
{
obj#ID_BASEOBJECT_XRAY=TRUE;
}
else
{
obj#ID_BASEOBJECT_XRAY=FALSE;
}
EventAdd();
return;
}
/////////
// Main
main()
{
// Get the icon
var fn = GeGetRootFilename();
fn->RemoveLast();
fn->AddLast("xrayicon.tif");
tagIcon = new(BaseBitmap,1,1);
tagIcon->Load(fn);
// Registers the tag
Register(xrayTag);
}
Does anyone have a small example of doing this?
Feel free to edit the code I posted and insert an attribute, or two, for the tag. If that's more convenient.
-ScottA
