Display of .stl files

Hello AnyBody Team,

I am a relatively new user of the AnyBody 5.2 system and I am working with the John Wu (beta) finger model. I have a number of questions and will simply post them in one thread unless you advise that I should make them all separate:

Question 1: I am having trouble getting our .stl files to display. The existing files that came with the model display without problem but new files do not, regardless of whether they are binary or ascii encoded. I have also dramatically increased the scale (enlarged) the display to make sure I am not missing them. These files open with other software just fine so I am having trouble figuring out what is going on here. Do you have any ideas for figuring this out?

Question 2: I have had some success in modifying the index finger model by duplicating the existing index finger in a different location but I did not realize this was correctly done until I was able to run the model. Upon initially loading the model the added finger displays in the same location as the other finger (exactly coincident with the other finger) so it looks like nothing has been done. In this model I do not have an obvious input to change the initial position so is there another way to get the initial position to display correctly upon loading the model?

Question 3: This is a general question regarding how to approach the use of C3D data with a marker set that is different from the PlugInGait set - i.e. markers on the hand. I have experimented with the GaitFullBody example and was able to read in a C3D file for a novel marker set (not the example data) but had some problems. Before I spend too much more time working with this model how would you recommend that I start? Another issue is that we will have fewer than 3 markers on each segment for the hand due to lack of space.

Thanks for your help!

Hello Jeremy,

Welcome to the community.

Q1: Most likely your surface models (STLs) are in millimeters and it happens that during drawing they are beyond the bounding box of the visualization scene. I recommend to use ScaleXYZ member of the surface classes to scale it down.

ScaleXYZ={1,1,1}*0.001;

In case this quick fix does not help - we can check your file.

Q2: You can add a parent ref. frame to your second model and move the origin by some distance. Possibly there is already a GlobalRef defined somewhere - just add the translation.


  AnyFixedRefFrame <ObjectName> = 
  {
    //Origin = {0, 0, 0};
    //Axes = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  };

Q3: Our wiki-page contains some useful information that should help you to start with your model, please check it: here

Best regards,

Pavel

Pavel,

Thanks for your quick reply. Unfortunately, I have not luck had any luck with the first two suggestions

Q1 reply: I have already tried and tried once more to scale the file really big and small as you suggested. I also hid everything else to make sure it wasn’t blocked. I tried to attach one of the files and I received an error that the file was invalid.

Q2:

AnyFolder Segs = {

AnyFixedRefFrame ThumbGlobalRef = {

      Origin = {-0.075, -0.018, -0.018};
      
      // Rotation matrix ///////////////////////////////////
      
      AnyVar E1d  = -160;  // x Euler angle in deg 
      AnyVar E2d  = 5;  // y Euler angle in deg
      AnyVar E3d  = -70; // z Euler angle in deg
      AnyVar E1 = E1d*pi/180; // converter to rad
      AnyVar E2 = E2d*pi/180; // converter to rad
      AnyVar E3 = E3d*pi/180; // converter to rad
      
      Axes = { {cos(E2)*cos(E3), -cos(E1)*sin(E3)+sin(E1)*sin(E2)*cos(E3),  sin(E1)*sin(E3)+cos(E1)*sin(E2)*cos(E3)}, 
               {cos(E2)*sin(E3),  cos(E1)*cos(E3)+sin(E1)*sin(E2)*sin(E3), -sin(E1)*cos(E3)+cos(E1)*sin(E2)*sin(E3)},
               {   -sin(E2)    ,             sin(E1)*cos(E2)             ,                  cos(E1)*cos(E2)        }};
             
      //////////////////////////////////////////////////////
	
      
      AnyDrawRefFrame DrwGlobalRef = {   ////////////////////////////////////
        ScaleXYZ = {1,1,1}/20;							     //
        RGB={0.5,0.5,0.5};           // only this stuff displays when loading //	       
                 //
      };										//   				
      AnyRefNode Trapezium = { sRel = {0,0,0}; };					//
      AnyRefNode Met_CMC = { 							//	
        sRel = {0.0,0.0,0.0};  //sRel = {-0.010,-0.000,-0.00};					//
        AnySurfEllipsoid Met_CMC = 							//
        {										//
          Radius = {0.012, 0.012, 0.012};						//
          AnyDrawParamSurf trapezium = 						//
          {										//
            RGB = {0.8, 0.5, 0.5};							//
            ScaleXYZ = {1, 1, 1};							//
          };									//
        };										//
      };					//////////////////////////////////////////////////////////////////////////////////			


    AnySeg Distal_Phalanx_1 = {
// Bunch of stuff to define the segment	
    }; // Distal_Phalanx_1
    
    AnySeg Proximal_Phalanx_1 = {
// Bunch of stuff to define the segment          
    }; // Proximal_Phalanx_1
    
    AnySeg Metacarpal_1 = {
// Bunch of stuff to define the segment
    }; // Metacarpal_1

         }; // Thumb global ref 

}; // Segs folder

Pavel,

My apologies, I was trying to format the code in text and hit tab and return and accidentally submitted! So I will continue where I left off…

Q2: I had already placed an additional global ref frame at the location of the copied (new) finger so I tried placing the global reference frame around the segment definitions of the new finger but that appears to have made no difference. Any ideas? Below is the copied code with some things omitted to make it shorter.

Thank you!

AnyFolder Segs = {

  AnyFixedRefFrame ThumbGlobalRef = {
      
      Origin = {-0.075, -0.018, -0.018};
      
      Axes = { rotation matrix };
	
      
      AnyDrawRefFrame DrwGlobalRef = {    	
        ScaleXYZ = {1,1,1}/20;							
        RGB={0.5,0.5,0.5};					
      };										   				
      AnyRefNode Trapezium = { sRel = {0,0,0}; };					
      AnyRefNode Met_CMC = { 								
        sRel = {0.0,0.0,0.0};  //sRel = {-0.010,-0.000,-0.00};					
        AnySurfEllipsoid Met_CMC = 							
        {										
          Radius = {0.012, 0.012, 0.012};						
          AnyDrawParamSurf trapezium = 						
          {										
            RGB = {0.8, 0.5, 0.5};							
            ScaleXYZ = {1, 1, 1};							
          };									
        };										
      };								


    AnySeg Distal_Phalanx_1 = {
// Bunch of stuff to define the segment	
    }; // Distal_Phalanx_1
    
    AnySeg Proximal_Phalanx_1 = {
// Bunch of stuff to define the segment          
    }; // Proximal_Phalanx_1
    
    AnySeg Metacarpal_1 = {
// Bunch of stuff to define the segment
    }; // Metacarpal_1

}; // Thumb global ref

}; // Segs folder

Jeremy,

Please post your visualization code for Q1. But it is supposed to look like:


  AnyDrawSurf mybone = {
    FileName = "Data\mybone.stl";
    ScaleXYZ = {1,1,1}*0.001;
    RGB = {0,0,1};
    //AnyFunTransform3D &sc = ..Something; 
  };    

Regarding Q2: I suggest you try with a new simple example. Make 2 global ref. frames and add identical segments to each - visualize this configuration. When that works - apply to your model. It is very difficult to analyze what went wrong from the code you sent.

Best regards,
Pavel

Q2: I also tried AnyDrawSurf with no luck. Here’s the code:

       AnyDrawSTL DrwSurf = { 
          FileName = "Index Distal.stl"; 
          ScaleXYZ = {1, 1, 1}/0.001; //also tried 0.0001,1000, & 10000
          Opacity = 1;
          RGB = {0.95, 0.75, 0.35};
        };

/.001 is bad - that means your object is scanned in micrometers and way bigger than the scene bounding box. *0.001 will convert from mm to m. Can you visualize/compute bounding box of your STL in another software package to check the exact dimensions? I still suspect it is something simple like the units problem - please double check. Otherwise please send me your file - i’ll figure out what is wrong.

Pavel

Hi,

So I checked the file - i guess the ascii files did not work because of the scaling factor, and now the problem was in the binary part:

      AnyDrawSurf a = {
        FileName= "Index Distal_ascii.stl";
        ScaleXYZ={1,1,1}*0.01; // conversion from cm to meters
      };

I was a bit distracted by this message: “The existing files that came with the model display without problem but new files do not, regardless of whether they are binary or ascii encoded.”

So just convert it to ascii in Meshlab and it is ready to use.

Best regards,
Pavel

Pavel,

Regarding Q1, it now works - thank you! FYI: I found software called netlab to move the origin within the STL file, otherwise the display body always rotates about a far-off axis.

Q2. I have done what you recommended and used the simple arm model provided in the examples. I have the same problem so this should be good for debugging. The first arm shows up when you load the model but the second does not show up until you run the model. Please load and run the uploaded file titled Practice Arm Model2 and let me know if you have any ideas.

Thanks again,

Jeremy

Hi Jeremy,

Q1: Good, but you can also do it within AnyBody by adding a relative reference frame and using sRel of AnyRefNode. Or like in Q2 giving some value to Origin of some reference frame.

Q2: Wrong implementation. Reference frames have to be nested in order to become relative to each other (like nodes in segments, which are also ref. frames). Try following code and do the same:


AnyFixedRefFrame GlobalRef1 = {
  Origin = {0,0,0};
  AnySeg s= {Mass=0;Jii={0.1,1,0.1};AnyDrawSeg a={};};
};
AnyFixedRefFrame GlobalRef2 = {
  Origin = {1,0,0};
  AnySeg s= {Mass=0;Jii={0.1,1,0.1};AnyDrawSeg a={};};
};

Best regards,
Pavel

The simple script that you sent has the same issue. I tried loading exactly what you sent me and I also tried nesting the second global ref frame within the other one and neither display two separate bodies. I looks as though the bodies are displayed exactly coincident even though their origins are different. Please load the two files I attached and see what happens.

Thanks,

Jeremy

Hi Jeremy,

I am very sorry. I was suggesting a wrong solution.

AnySeg doesn’t have an sRel member as AnyRefNode has. This means that you can only assign global coordinates to it using r and r0 members. And to visualize it slightly different on loading you would need to use r0 member (initial position).
So the code would look like:


  // The actual body model goes in this folder
  AnyFolder MyModel = {
    AnyFixedRefFrame GlobalRef1 = {}; // default origin {0,0,0};
    AnyFixedRefFrame GlobalRef2 = {
      Origin={0,1,0};
    }; 
    AnySeg a1= {
      Mass=0;Jii={1,0.1,1};
      r0 = {0,1,0};
      AnyDrawSeg a={};
    };
    AnySeg a2= {
      Mass=0;Jii={1,0.1,1}; 
      r0 = .GlobalRef2.Origin+.a1.r0;
      AnyDrawSeg a={};
    };
  }; // MyModel

Best regards,
Pavel