I am trying to select all objects like node selectedallobject in visual scripting.
used this method :
sel_objects = AllplanBaseElements.ElementsSelectService.SelectAllElements(self.coord_input.GetInputViewDocument())
But Allplan crashes
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.
Melden Sie sich jetzt an und diskutieren Sie mit!
I am trying to select all objects like node selectedallobject in visual scripting.
used this method :
sel_objects = AllplanBaseElements.ElementsSelectService.SelectAllElements(self.coord_input.GetInputViewDocument())
But Allplan crashes
Hi,
the problem is that you have created a new, empty document adapter:
sel_elements = AllplanBaseElements.ElementsSelectService.SelectAllElements(AllplanElementAdapter.DocumentAdapter())
What you do is you define a function called create_element. Allplan calls this function when he needs to (e.g. when you start the PythonPart). When it does so, it gives 2 arguments to it: build_ele (of type BuildingElement) and doc (of type DocumentAdapter).
The first one represents the data, that is input in the property palette: the parameters and their values. The latter, document adapter, stands for the whole content of the currently opened drawing file(s). Everything, what is in the currently opened drawing files, like lines, dimension lines, UVSs, but also stuff like layer definition, available steel grades... Basically everything is inside this object.
What you have done with...
sel_elements = AllplanBaseElements.ElementsSelectService.SelectAllElements(AllplanElementAdapter.DocumentAdapter())...is you have created a new empty document and you tried to select elements from it. This won't work.
Instead, use the document, Allplan is giving to you as an argument of the create_element function:
def create_element(build_ele: BuildingElement, doc: AllplanElementAdapter.DocumentAdapter) -> CreateElementResult: sel_elements = AllplanBaseElements.ElementsSelectService.SelectAllElements(doc) # now do something with the elements ...
Best,
Bart
for polyline in polyline_elements: moved_polyline = AllplanGeometry.Move(polyline,vectormove)
At the very end, you should create these polylines in the drawing fileAllplanBaseElements.CreateElements(doc, AllplanGeometry.Matrix3D(), model_ele_list, [], None)
Have a look at the script. You can run it in Allplan. Create some 3D polylines beforehand and then run it and click "Go!".
Best,
Bart
Thank, works like a charm.
def on_control_even is useful for me.