I'm facing troubles with SelectElementsService. I want to use SelectByRect method but i cannot initilize SelectElementsService not as class not as instance. I always get a None
Das Wissen aller Anwender nutzen
Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.
Es erwarten Sie:
- Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
- Tipps von User für User
- international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch
Melden Sie sich jetzt an und diskutieren Sie mit!
- Forum
- CAD Parametric Modelling
- PythonParts
[Frage] SelectElementsService
Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen
Hi,
SelectElementsService does not have a contructor and thus cannot and doesn't have to be initialized. What you are probably facing here is just a mismatch of given vs. expected arguments. You have given 5 arguments, but the function expects 6. Seems, that there is a mistake in the documentation. Here is an example of how you should call the method:
selected_elements = AllplanIFW.SelectElementsService.SelectByRect( self.document, # <---- the document adapter is missing in the function signature AllplanGeometry.Point2D(-10000,-10000), AllplanGeometry.Point2D(10000,10000), self.coord_input.GetViewWorldProjection(), AllplanIFW.SelectElementsService.eSelectCondition.SELECT_ALL, AllplanIFW.SelectionQuery())
I don't know, what is your use-case here, but please note, that the Point2D you are giving here is the point in local coordinates of the viewport and NOT in global coordinates. The origin (0,0) is always exactly in the middle of the viewport. This function is meant to handle a user interaction (which is done on a flat computer screen).
Hope that helps.
Best, Bart
Hi,
SelectElementsService does not have a contructor and thus cannot and doesn't have to be initialized. What you are probably facing here is just a mismatch of given vs. expected arguments. You have given 5 arguments, but the function expects 6. Seems, that there is a mistake in the documentation. Here is an example of how you should call the method:
selected_elements = AllplanIFW.SelectElementsService.SelectByRect( self.document, # <---- the document adapter is missing in the function signature AllplanGeometry.Point2D(-10000,-10000), AllplanGeometry.Point2D(10000,10000), self.coord_input.GetViewWorldProjection(), AllplanIFW.SelectElementsService.eSelectCondition.SELECT_ALL, AllplanIFW.SelectionQuery())
I don't know, what is your use-case here, but please note, that the Point2D you are giving here is the point in local coordinates of the viewport and NOT in global coordinates. The origin (0,0) is always exactly in the middle of the viewport. This function is meant to handle a user interaction (which is done on a flat computer screen).
Hope that helps.
Best, Bart