Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    I want to get the coordinates of the points I have selected "en"

    Cinema 4D SDK
    r21 c++ windows
    2
    4
    802
    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.
    • D
      dada
      last edited by Manuel

      User Information:
      Cinema 4D Version: 21.115
      Platform: Windows ;
      Language(s) : C++ ;
      I've converted objects to polygons,
      And selected a point

      And print out the serial number of these points

      How can I get the coordinates of these points

      Here's my code

      BaseDocument*doc = GetActiveDocument();
      
      BaseObject * obj1 = doc->GetActiveObject();
      
      if (obj1->GetType()!= Opolygon)
      		{
      			break;
      		}
      PointObject *slpoint = ToPoint(obj1);
      BaseSelect *pointsel = slpoint->GetPointS();
      		
      			
      
      Int32 seg = 0, i, a, b;
      while (pointsel->GetRange(seg++, LIMIT <Int32> ::MAX,&a,&b))
      		{
      			for ( i = a; i < b; i++)
      			{
      				
      				ApplicationOutput("aa: @"_s, i);
      
      			}
      
      			
      		}
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        hello,

        For your next threads, please help us keeping things organised and clean.

        • Q&A New Functionality.
        • How to Post Questions especially the tagging part.

        I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

        you can use GetPointR to retrieve the points array pointer.

        You will retrieve the point in object position so you have to multiply by the matrix of the object to retrieve the world coordinate of the point.

        Watch out that your range could have only one point so be careful with the condition of the for loop and use inforior or equal to b

        for (i=a; i<=b; ++i)
        

        Something like this will work

                PointObject *slpoint = ToPoint(obj1);
        	BaseSelect *pointsel = slpoint->GetPointS();
        	const maxon::Vector* padr = slpoint->GetPointR();
        	const maxon::Matrix opmg = slpoint->GetMg();
        
        	Int32 seg = 0, i, a, b;
        	while (pointsel->GetRange(seg++, LIMIT<Int32>::MAX, &a, &b))
        	{
        		for (i = a; i <= b; i++)
        		{
        			const maxon::Vector pointPosition = padr[i];
        			const maxon::Vector worldPointPosition = opmg * pointPosition ;
        
        			ApplicationOutput("aa index : @, object position @, wordl position @", i, pointPosition, worldPointPosition);
        
        		}
        
        
        	}
        
        
        

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        D 2 Replies Last reply Reply Quote 0
        • D
          dada @Manuel
          last edited by

          @m_magalhaes
          非常感谢
          我用另外一个办法解决了不用求矩阵
          代码如下

          PointObject *slpoint = ToPoint(obj1); //转换为点对象
          		BaseSelect *pointsel = slpoint->GetPointS();//获取选择的点
          
          		Int32 pointConst = slpoint->GetPointCount();//获取所有的点
          		Vector *points = slpoint->GetPointW();//获取所有点的坐标
          		Vector pt;
          		Int32 i;
          		for (i = 0; i < pointConst; i++)//利用for循环来不断读取所有点的数据
          		{
          			if (pointsel->IsSelected(i))//来判断当前的点是否选择住
          			{
          				pt += points[i];//若果选择 所有向量相加
          			}
          		}
          
          1 Reply Last reply Reply Quote 0
          • D
            dada @Manuel
            last edited by

            @m_magalhaes
            I'll write it in your way

            Thank you very much.

            Cheers!

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