EXISTS(nged)
The exists command evaluates an expression and returns 1 if true, 0 if false. It serves roughly the same purpose for objects in a BRL-CAD database that the UNIX test command serves for files on aβ¦
π NAME π
exists β okay so this is the EXISTS(nged) manual page, and exists is the command that evaluates an expression and returns 1 if true, 0 if false. It serves roughly the same purpose for objects in a BRL-CAD database that the UNIX test command serves for files on a file system, with additional features specific to geometry. slay.
β¨ SYNOPSIS β¨
exists {expression} [expression]...
π¦ DESCRIPTION π¦
Bestie, here's the vibe: exists evaluates boolean expressions about objects in the currently open database, returning 1 (true) or 0 (false). It is modelled on Unix-style test(1) commands (internally based on NetBSD's test code), but it tests objects rather than files. iconic behavior, honestly.
Expressions are built from PRIMARIES and OPERATORS. A bare object name with no primary or operator returns true if the object exists in the database and is not a phony placeholder (same as -N). no cap.
On a parse error (e.g. missing operand, unmatched parenthesis) the command returns an error status and writes a diagnostic message rather than 0. do not ignore this, bestie β parse errors are not a vibe.
π PRIMARIES π
-c objectβ ReturnsTRUEifobjectexists and is a combination. combo energy.-e objectβ ReturnsTRUEifobjectexists. This reports only the result ofdb_lookupwithout further checking, and is the most basic existence test. literally the bare minimum check.-n objectβ ReturnsTRUEifobjectexists in the directory but is a phony placeholder (itsd_addrisRT_DIR_PHONY_ADDR, meaning it has been added to the directory but not yet written to disk). Ordinary objects are never null. spooky placeholder behavior, but valid.-p objectβ ReturnsTRUEifobjectexists and is a geometric primitive (i.e. it has the solid flag set and is not a non-geometry object). Empty geometric primitives and 2D primitives likesketchpass this test. primitive princess.-v objectβ ReturnsTRUEifobjectexists and its axis-aligned bounding box has non-zero volume. Asketchprimitive (2D) does not pass this test; neither does a missing object. volume check says what it says.object1 = object2β ReturnsTRUEif both objects exist and the serialised geometry bodies of both objects are identical (same length and same bytes). The object name is excluded from the comparison, so a direct copy of an object usingcpwill compare as equal. copy-paste twins.object1 != object2β ReturnsTRUEif both objects exist and their serialised geometry bodies differ (different length or at least one differing byte). not matching, not slaying.object1 < object2β ReturnsTRUEif both objects exist and the size (in bytes) of the serialised geometry body ofobject1is less than that ofobject2. smaller body, big main character energy.object1 > object2β ReturnsTRUEif both objects exist and the size (in bytes) of the serialised geometry body ofobject1is greater than that ofobject2. bigger body, bigger flex.object1 -beq object2β ReturnsTRUEif both objects exist and the volumes of their bounding boxes are equal (within floating-point tolerance). equal-ish, but make it geometry.object1 -bne object2β ReturnsTRUEif both objects exist and the volumes of their bounding boxes are not equal. not equal, periodt.object1 -bgt object2β ReturnsTRUEif both objects exist and the bounding-box volume ofobject1is strictly greater than that ofobject2. strictly bigger.object1 -bge object2β ReturnsTRUEif both objects exist and the bounding-box volume ofobject1is greater than or equal to that ofobject2. greater or equal, bestie.object1 -blt object2β ReturnsTRUEif both objects exist and the bounding-box volume ofobject1is strictly less than that ofobject2. strictly smaller.object1 -ble object2β ReturnsTRUEif both objects exist and the bounding-box volume ofobject1is less than or equal to that ofobject2. less or equal, and that's that.
π OPERATORS π
Primaries can be combined with the following operators:
! expressionβ True ifexpressionis false. the classic "not me" operator.expression -a expressionβ The and operator βTRUEonly if both expressions are true. both have to eat.expression -o expressionβ The or operator β true if either expression is true. either one can carry.( expression )β Evaluates to true if the expression inside the parentheses evaluates to true. Used to establish order of operations. parentheses are the group-chat reply threads of parsing.
The -a operator has higher precedence than the -o operator. iykyk.
πΈ A NOTE ON EXPRESSIONS πΈ
All primaries and operands must be expressed as separate arguments to exists. In practice, this means that there must be a space between each element in an exists expression. E.g. !(-c object1.s -a (object1.s -beq object2.s)) must be written as:
! ( -c object1.s -a ( object1.s -beq object2.s ) )
While this may seem like a rather verbose way of writing the expression, it greatly simplifies the parsing of the expression and is standard for virtually all test type commands. trust the process, bestie.
π₯ EXAMPLES π₯
The following are run from the MGED command prompt:
Example 1. Check whether an object exists
mged> exists object1.s
1
Example 2. Check if an object is a combination
mged> exists -c object1.r
1
Example 3. Use logical operators
mged> exists -c object1.r -a -e object1.s
1
Example 4. Compare bounding-box volumes
mged> exists big_sphere.s -bgt small_sphere.s
1
π DIAGNOSTICS π
Returns 1 (true) or 0 (false) on success, and writes a diagnostic message to the result string while returning an error status on parse failures (missing operands, unmatched parentheses, or unexpected tokens). parse fail is not a look.
π AUTHOR π
BRL-CAD Team. periodt.
π COPYRIGHT π
This software is Copyright (c) 2008-2026 United States Government as represented by the U.S. Army Research Laboratory. Portions Copyright 1990, 1993, 1994 The Regents of the University of California, per copyright and license information from OpenBSD and NetBSD. For more details see the copyright statements in exists.c. legal text but make it cute.
π BUG REPORTS π
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org. please do, bestie.
That's the whole page, bestie β brought to you by BRL-CAD and filed under EXISTS(nged) π The footer doesn't give a date, so I'm not inventing one β just sending pure vibes and accurate manual energy. π
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms