Dynamically changing color of entity created with ruby is very slow

Also, for code in the forum, see:

[How to] Colourize code on the forum? (pinned topic)

I would encourage you to follow Ruby’s 2 space indent rule, as it will make your code more readable, and maintainable.

def create_entity
  return @entity if @entity
  translation = Geom::Transformation.translation(@center)
  rotation_angle = Geometry.rotation_angle_between(
    Geometry::Z_AXIS,
    @vector
  )
  rotation_axis = Geometry.perpendicular_rotation_axis(
    Geometry::Z_AXIS,
    @vector
  )
  rotation = Geom::Transformation.rotation(
    @center,
    rotation_axis,
    rotation_angle
  )
  transformation = rotation * translation
  entity = Sketchup.active_model.active_entities.add_instance(
    @definition,
    transformation
  ).make_unique
  entity
end

This also gives space for comments after method arguments.