The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (Archicad API, BIMx API, BIMcloud API) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy

By scandi
#316560
Hi, guys.

I am trying to make the add-on do something when the sight change. I look into the SDK and find class ISightObserver may relate with my requirement. Could you please help me use it? Is there any sample?

Thanks in advance.
User avatar
By Kristian Bursell
#316568
is Shawn Hopkins (BIM Bakery) on this forum? They had a sight observer tool for stadiums, hence he may be able to help you.
By scandi
#316652
I have solved it. Here is my code (maybe someone will find it helpful):
Code: Select all
class MySightObserver: public Modeler::ISightObserver {

public:
	Modeler::Camera cam;
	void CameraChanged(const Modeler::Camera&);

};
MySightObserver mso;

MySight::MySight(Modeler::Sight *sig){
	mysight = sig;
	myobserver = &mso;
	((MySightObserver*)myobserver)->cam = sig->GetCamera();
	sig->Attach(*myobserver);
}

void MySightObserver::CameraChanged(const Modeler::Camera& newCamera) {
	if (!newCamera.IsNear(cam)) {
              /*Your code here*/
	}
	return;
}

PS: You need to fetch the Modeler::Sight (see my another post) and create an instance of MySightObserver.