License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
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.