Point/Vertex ID's in Macros

Any questions regarding the practice version are asked and answered here.
Post Reply
Elliot Bladen
Posts: 5
Joined: Fri Jun 03, 2022 1:59 pm

Point/Vertex ID's in Macros

Post by Elliot Bladen »

Hey,

Does any body know what function to call for comparing Point/Vertex ID's in 12d macro language?

I have 2 models. I would like to compare both sets of data by looping through both models and matching their Point/Vertex ID's together.

Cheers,
Phil Temple-Watts
Posts: 318
Joined: Thu Jun 27, 2019 10:49 am
Location: Hobart

Re: Point/Vertex ID's in Macros

Post by Phil Temple-Watts »

Hi Elliot,

There's no direct call to compare them - you'd need two Text variables to get the return values, and then manually compare those values for each individual vertex of each individual string (element).

The call you want is:
Get_super_vertex_point_number(Element super,Integer vert,Text &point_id)
:)
Elliot Bladen
Posts: 5
Joined: Fri Jun 03, 2022 1:59 pm

Re: Point/Vertex ID's in Macros

Post by Elliot Bladen »

Thanks Phil, Appreciate that

I have called the function( Get_super_vertex_point_number(Element super,Integer vert,Text &point_id))

However I can't get them to compare properly. How would you name your variables and structure code into getting the function to work.

Any pointers/tips would be greatly appreciated.

Cheers,

Elliot
paul hardwick
Posts: 1639
Joined: Thu Dec 06, 2007 9:27 am

Re: Point/Vertex ID's in Macros

Post by paul hardwick »

You would happen to be in V15 at all?
There's some great new macro call that would make this super simple.

But in V14 something like this should work.

WARNING not tested just an idea

Code: Select all

void add_point_data(Dynamic_Element de,Attributes &pointList)
{
    Integer count =0;
    Get_number_of_items(de,count);
    for (Integer i=1; i<= count; i++) 
    {
        Element elt;
        Get_item(de,i,elt); 
        Integer use=0;
        Get_super_use_vertex_point_number(elt,use);
        if(use==0)continue;
        Integer points=0;
        Get_points(elt,points);
        for (Integer j=1; j<= points; j++) 
        {
            Text number="";
            Get_super_vertex_point_number(elt,j,number);
            Valid_attribute_name(number,number);
            if(number=="")continue;
            Real x,y,z;
            Null(x);Null(y);Null(z);
            Get_super_vertex_coord(elt,j,x,y,z);
            Set_attribute(pointList,number+"/x",x);
            Set_attribute(pointList,number+"/y",y);
            Set_attribute(pointList,number+"/z",z);             
        }
    }
}
void main()
{
    Dynamic_Element deDesign,deSurvey;
    //load your deDesign some how e.g model, source_box
    //load your deSurvey some how e.g model, source_box    
   
    Attributes pointList;
    //Get the points that have point ids
    add_point_data(deDesign,pointList);




    //Now step through your survey data

    Integer count =0;
    Get_number_of_items(deSurvey,count);
    for (Integer i=1; i<= count; i++) 
    {
        Element elt;
        Get_item(deSurvey,i,elt); 
        Integer use=0;
        Get_super_use_vertex_point_number(elt,use);
        if(use==0)continue;
        Integer points=0;
        Get_points(elt,points);
        for (Integer j=1; j<= points; j++) 
        {
            Text number="";
            Get_super_vertex_point_number(elt,j,number);
            Valid_attribute_name(number,number);
            if(number=="")continue;
            Real x1,y1,z1,x2,y2,z2;
            Null(x1);Null(y1);Null(z1);
            Null(x2);Null(y2);Null(z2);
            Get_super_vertex_coord(elt,j,x1,y1,z1);
            if(Get_attribute(pointList,number+"/x",x2)!=0)continue;
            if(Get_attribute(pointList,number+"/y",y2)!=0)continue;
            if(Get_attribute(pointList,number+"/z",z2)!=0)continue;      

            //if you made it here you have two point with the same name 

            //Now compare them
            Real dx =    x1-x2;
            Real dy =    y1-y2;
            Real dz =    z1-z2;
        }
    }

}
Paul Hardwick
12d Support Qld
Post Reply