Support Forum

[Frage] SelectElementsService


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

Anhänge (1)

Typ: image/jpeg
23-mal heruntergeladen
Größe: 45,60 KiB

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