Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Sight Observer

Anonymous
Not applicable
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.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Anonymous
Not applicable
I have solved it. Here is my code (maybe someone will find it helpful):

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.

View solution in original post

2 REPLIES 2
is Shawn Hopkins (BIM Bakery) on this forum? They had a sight observer tool for stadiums, hence he may be able to help you.
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
Solution
Anonymous
Not applicable
I have solved it. Here is my code (maybe someone will find it helpful):

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.