@@ -90,6 +90,252 @@ def _run(self, command: str, params: any = None):
9090 self .act .AddOnCommandId ("TapirCommand" , command )
9191 )
9292
93+ # region Application Commands
94+ def getTapirVersion (self ) -> str :
95+ """Retrieves the version of the installed Tapir Add-On."""
96+ name_ = "GetAddOnVersion"
97+ return self ._run (name_ )["version" ]
98+
99+ def getArchicadLocation (self ) -> str :
100+ """Retrieves the location of the currently running Archicad executable."""
101+ name_ = inspect .currentframe ().f_code .co_name
102+ return self ._run (name_ )["archicadLocation" ]
103+
104+ def quitArchicad (self ) -> dict :
105+ """Performs a quit operation on the currently running Archicad instance."""
106+ name_ = inspect .currentframe ().f_code .co_name
107+ return self ._run (name_ )
108+
109+ def getCurrentWindowType (self ) -> str :
110+ """Returns the type of the current (active) window."""
111+ name_ = inspect .currentframe ().f_code .co_name
112+ return self ._run (name_ )["currentWindowType" ]
113+
114+ # endregion
115+ # region Project Commands
116+ def getProjectInfo (self ) -> dict :
117+ """Retrieves information about the currently loaded project."""
118+ name_ = inspect .currentframe ().f_code .co_name
119+ return self ._run (name_ )
120+
121+ def getProjectInfoFields (self ) -> dict :
122+ """Retrieves the names and values of all project info fields."""
123+ name_ = inspect .currentframe ().f_code .co_name
124+ return self ._run (name_ )
125+
126+ def getStories (self ) -> dict :
127+ """Retrieves information about the story sructure of the currently loaded project."""
128+ name_ = inspect .currentframe ().f_code .co_name
129+ return self ._run (name_ )
130+
131+ def getHotlinks (self ) -> dict :
132+ """Gets the file system locations (path) of the hotlink modules. The hotlinks can have tree hierarchy in the project."""
133+ name_ = inspect .currentframe ().f_code .co_name
134+ return self ._run (name_ )
135+
136+ def openProject (self , path : str | Path ) -> dict :
137+ """Opens the given project."""
138+ name_ = inspect .currentframe ().f_code .co_name
139+ path = _validate_path (path , io_op = "r" )
140+ params = {"projectFilePath" : path }
141+ return self ._run (name_ , params )
142+
143+ def getGeoLocation (self ) -> dict :
144+ """Gets the project location details."""
145+ name_ = inspect .currentframe ().f_code .co_name
146+ return self ._run (name_ )
147+
148+ # endregion
149+ # region Element Commands
150+
151+ # The following commands are not integrated, since Perisso covers it:
152+ # GetSelectedElements
153+ # GetElementsByType
154+ # GetAllElements
155+ # ChangeSelectionOfElements
156+ # FilterElements
157+
158+ def getDetailsOfElements (self , elements : List [Dict [str , str ]]) -> dict :
159+ """Get details of given elements."""
160+ name_ = inspect .currentframe ().f_code .co_name
161+ params = {"elements" : elements }
162+ return self ._run (name_ , params )
163+ def get3DBoundingBoxes (self , elements : List [Dict [str , str ]]) -> Dict [str , Any ]:
164+ """Get 3D bounding boxes of elements."""
165+ name_ = inspect .currentframe ().f_code .co_name
166+ params = {"elements" : elements }
167+ return self ._run (name_ , params )
168+
169+ def getConnectedElements (
170+ self , elements : List [Dict [str , str ]], connectedElementType : ElType
171+ ) -> dict :
172+ """Gets the subelements of the given hierarchical elements."""
173+ name_ = inspect .currentframe ().f_code .co_name
174+ params = {
175+ "elements" : elements ,
176+ "connectedElementType" : connectedElementType .value ,
177+ }
178+ return self ._run (name_ , params )
179+
180+ def highlightElements (
181+ self ,
182+ elements : Dict [str , str ] = None ,
183+ * ,
184+ hightlightcolor : list [list [int ]] = [[77 , 235 , 103 , 100 ]],
185+ mutedcolor : list [int ] = [164 , 166 , 165 , 128 ],
186+ wireframe = True ,
187+ ) -> None :
188+ """Highlight the elements in the given color and mutes all other elements."""
189+ name_ = inspect .currentframe ().f_code .co_name
190+ params = {
191+ "elements" : elements ,
192+ "highlightedColors" : hightlightcolor ,
193+ "wireframe3D" : wireframe ,
194+ "nonHighlightedColor" : mutedcolor ,
195+ }
196+ return self ._run (name_ , params )
197+
198+ def clearHighlight (self ):
199+ """Clear all highlighting in Archicad."""
200+ # A helper function – this does not exist as it's own Tapir command.
201+ return self .highlightElements (elements = [None ])
202+
203+ def moveElements (
204+ self , elements : Dict [str , str ], vector : Vector , copy : bool = False
205+ ):
206+ """Moves elements with a given vector."""
207+ name_ = inspect .currentframe ().f_code .co_name
208+ params = {
209+ "elementsWithMoveVectors" : [
210+ {
211+ "elementId" : el ["elementId" ],
212+ "moveVector" : vector .to_3d ().to_dict (),
213+ "copy" : copy ,
214+ }
215+ for el in elements
216+ ]
217+ }
218+ return self ._run (name_ , params )
219+
220+ def getGDLParametersOfElements (self , elements : List [Dict [str , str ]]) -> dict :
221+ """Gets all the GDL parameters (name, type, value) of the given elements."""
222+ name_ = inspect .currentframe ().f_code .co_name
223+ params = {"elements" : elements }
224+ return self ._run (name_ , params )
225+ # endregion
226+ # region Create Elements
227+ def createColumns (self , coors : List [Coordinate ]) -> dict :
228+ """Creates Column elements based on the given parameters."""
229+ name_ = inspect .currentframe ().f_code .co_name
230+ params = {
231+ "columnsData" : [{"coordinates" : coor .to_3d ().to_dict ()} for coor in coors ]
232+ }
233+ return self ._run (name_ , params )
234+ # endregion
235+ # region Favorites Commands
236+ def applyFavoritesToElementDefaults (self , favoriteNames : str ) -> dict :
237+ """Apply the given favorites to their respective element tool defaults."""
238+ name_ = inspect .currentframe ().f_code .co_name
239+ params = {"favorites" : [favoriteNames ]}
240+ return self ._run (name_ , params )
241+
242+ def createFavoritesFromElements (
243+ self , elements : List [Dict [str , str ]], favoriteNames : List [str ]
244+ ) -> dict :
245+ """Create favorites from the given elements."""
246+ name_ = inspect .currentframe ().f_code .co_name
247+ if isinstance (favoriteNames , str ):
248+ # make sure we get a list
249+ favoriteNames = [favoriteNames ]
250+ params = {
251+ "favoritesFromElements" : [
252+ {
253+ "elementId" : el ["elementId" ],
254+ "favorite" : favname ,
255+ }
256+ for el , favname in zip (elements , favoriteNames )
257+ ]
258+ }
259+ return self ._run (name_ , params )
260+
261+ # endregion
262+ # region Property Commands
263+ def getAllProperties (self ) -> dict :
264+ """Returns all user defined and built-in properties."""
265+ name_ = inspect .currentframe ().f_code .co_name
266+ return self ._run (name_ )
267+
268+ def getPropertyValuesOfElements (
269+ self , elements : List [Dict [str , str ]], propertyGUIDs : List [str ]
270+ ) -> Dict [str , Any ]:
271+ """
272+ Get property values of elements.
273+
274+ Args:
275+ elements: List of element dictionaries with identification info
276+ properties: List of property parameters with propertyId mappings
277+
278+ Returns:
279+ Dictionary containing the property values for the requested elements
280+ """
281+ name_ = inspect .currentframe ().f_code .co_name
282+ params = {
283+ "elements" : elements ,
284+ "properties" : [{"propertyId" : {"guid" : pg }} for pg in propertyGUIDs ],
285+ }
286+ return self ._run (name_ , params )
287+ # endregion
288+ # region Attribute Commands
289+ # endregion
290+ # region Library Commands
291+ def getLibraries (self ) -> Dict [str , Any ]:
292+ """Gets the list of loaded libraries."""
293+ name_ = inspect .currentframe ().f_code .co_name
294+ return self ._run (name_ )
295+
296+ def reloadLibraries (self ) -> Dict [str , Any ]:
297+ """Executes the reload libraries command."""
298+ name_ = inspect .currentframe ().f_code .co_name
299+ return self ._run (name_ )
300+
301+ # endregion
302+ # region Teamwork Commands
303+ def _twTest (self , command : str ) -> bool :
304+ """Internal function that will warn if a file is not a TW file."""
305+ if not self .getProjectInfo ()["isTeamwork" ]:
306+ _printcol (f"Not a Teamwork file! Command »{ command } « will not be sent." )
307+ return False
308+ return True
309+
310+ def teamworkSend (self ) -> Dict [str , Any ]:
311+ """Performs a send operation on the currently opened Teamwork project."""
312+ name_ = inspect .currentframe ().f_code .co_name
313+ if self ._twTest (name_ ):
314+ return self ._run (name_ )
315+ return None
316+ # endregion
317+ # region Navigator Commands
318+
319+ # endregion
320+ # region Issue Management Commands
321+ # endregion
322+ # region Revision Management Commands
323+ def getRevisionIssues (self ) -> Dict [str , Any ]:
324+ """Retrieves all issues."""
325+ name_ = inspect .currentframe ().f_code .co_name
326+ return self ._run (name_ )
327+
328+ def getRevisionChanges (self ) -> Dict [str , Any ]:
329+ """Retrieves all changes."""
330+ name_ = inspect .currentframe ().f_code .co_name
331+ return self ._run (name_ )
332+
333+ def getDocumentRevisions (self ) -> Dict [str , Any ]:
334+ """Retrieves all document revisions."""
335+ name_ = inspect .currentframe ().f_code .co_name
336+ return self ._run (name_ )
337+ # endregion
338+
93339
94340# Export a singleton
95341tapir = TapirCommands ()
0 commit comments