public static AXParametricObject addNodeToCurrentModel(string nodeName, bool panTo = true, AXParametricObject basedOnPO = null)
    {
        AXModel model = getOrMakeSelectedModel();


        Undo.RegisterCompleteObjectUndo(model, "Add Generator named " + nodeName);


        AXParametricObject npo = model.createNode(nodeName, panTo, basedOnPO);

        if (npo == null)
        {
            return(null);
        }

        if (basedOnPO != null)
        {
            //Debug.Log("basedOnPO.Name="+basedOnPO.Name);
            basedOnPO.copyTransformTo(npo);
        }



        ArchimatixEngine.repaintGraphEditorIfExistsAndOpen();


        bool isInstanceofCurrentGrouper = ((npo.generator is IReplica) && model.currentWorkingGroupPO != null && basedOnPO == model.currentWorkingGroupPO);


        if (model.currentWorkingGroupPO != null)
        {
            List <AXParametricObject> npos = new List <AXParametricObject>();
            npos.Add(npo);


            if (!isInstanceofCurrentGrouper)
            {
                model.currentWorkingGroupPO.addGroupees(npos);
            }
        }

        if (isInstanceofCurrentGrouper)
        {
            model.currentWorkingGroupPO = model.currentWorkingGroupPO.grouper;
        }

        return(npo);
    }