Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    get selection poligon vertex and perform a scaling

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 179 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 26/08/2011 at 03:09, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   12 
      Platform:      
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      I'm using c.o.f.f.e.e. (no pytohon, no c++) i'm in polygon mode i would to do these things:

      1. enable menu plugin if the user is in polygon mode and has selected a poligon
      2. get all the list of polygon selected
      3. then perform a scaling but only for the X axis
         
        very big thanks!
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 30/08/2011 at 09:42, xxxxxxxx wrote:

        The state of the menu entry is controled via the MenuPlugin::GetState method. Override it for your own plugins. The other points are explained in my example.

          
        class MPPlugin : MenuPlugin  
        {  
          public:  
              MPPlugin();  
          
              GetID();  
              GetName();  
              GetState();  
                
              GetHelp();  
              Execute(doc);  
        }  
          
        MPPlugin::MPPlugin()  
        {  
          super();  
        }  
          
        MPPlugin::GetID()  
        {  
          return 1001150;  
        }  
          
        MPPlugin::GetState()  
        {  
          var doc = GetActiveDocument();  
          if (!doc) return 0;  
            
          // is polygon mode checked  
          if (!IsCommandChecked(12187)) return 0;  
          
          // is there an selected object and is it a polygon object  
          var op = doc->GetActiveObject();  
          if (!op || op->GetType() != Opolygon) return 0;  
            
          // is at least one polyogn selected  
          var sel = op->GetPolygonSelection();  
          if (sel->GetCount() == 0) return 0;  
            
          return CMD_ENABLED;  
        }  
          
        MPPlugin::GetName()  
        {  
          return "Scale Test";  
        }  
          
        MPPlugin::GetHelp()  
        {  
          return "Scale Test";  
        }  
          
          
        MPPlugin::Execute(doc)  
        {  
          var op = doc->GetActiveObject();  
          if (!op || op->GetType() != Opolygon) return 0;  
            
          var sel = op->GetPolygonSelection();  
          if (sel->GetCount() == 0) return;  
          
          var fcnt = op->GetPolygonCount();  
          var vcnt = op->GetPointCount();  
            
          // create a vertex index array to store selection states for vertices of selected polygons  
          var vidx = new(array,vcnt);  
          if (!vidx) return;  
            
          var i = 0;  
            
          // initialize the array  
          for (i=0; i<vcnt; i++)  
          {  
              vidx[i] = FALSE;  
          }  
            
          // converts polygon selection into point selection  
          for (i=0; i<fcnt; i++)  
          {  
              if (sel->IsSelected(i))  
              {  
                  var poly = op->GetPolygon(i);  
                  vidx[poly->a] = TRUE;  
                  vidx[poly->b] = TRUE;  
                  vidx[poly->c] = TRUE;  
                  vidx[poly->d] = TRUE;        }  
          }  
            
          // go through the vertices and do something (e.g scale)  
          for (i=0; i<vcnt; i++)  
          {  
              if (vidx[i])  
              {  
                  var vertex = op->GetPoint(i);  
                    
                  // do something with vertex  
                  vertex.x *= 5.0;  
                  //vertex.y *= 2.0;  
                  //vertex.z *= 3.0;   
                    
                  op->SetPoint(i, vertex);  
              }  
          }  
            
          // must be called for object and editor update  
          op->Message(MSG_UPDATE);  
          EventAdd();  
        }  
          
          
        main()  
        {  
          Register(MPPlugin);  
        }  
        

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • First post
          Last post