Get position of object-box

I want to draw a line in scene-view near the current object for debugging. I have trouble with getting the position with transform.position!

“NullReferenceException: Object reference not set to an instance of an object”

I tried Intantiate, Getcomponent, Transform.position,…nothings works. How do I get the position of the current object? I did read the documentation and also many posts here. Problem persists - otherwise I wouldn’t ask here.

2nd: Is renderer.bounds the right way to get the outer-coordinates of an object? I tried mesh.bounds before, but since there is no mesh attached, I couldn’t use it.

function simulate(){

 var targetline = false;     
 var drawcoor : Vector3;
 drawcoor = transform.position +  Vector3(renderer.Bounds.size.x,renderer.Bounds.size.y,renderer.Bounds.size.z);

  if (!targetline){
    Debug.DrawRay (drawcoor, Vector3(800, 0, 0), Color.white,60*24);        
    targetline=true;
  }

} //Endfunc simulate

The transform.position-problem just disappeared suddenly. To get boundaries of an object, transform.lossyScale is the key. Working version of script looks like this:

function simulate(){
 var targetline = false;
 var drawcoor : Vector3;

 drawcoor = transform.position + transform.lossyScale; 

  if (!targetline){
    Debug.DrawRay (drawcoor, Vector3 (drawcoor.x*10, 0, 0), Color.white,60);    

    Debug.Log("Current Position: "+transform.position +" Current Scale: "+transform.lossyScale);
    targetline=true;
  }
} //Endfunc sim