Is it possible to hide all objects within a specific Z-range?

Is it possible to hide all objects within a specific Z-range?

Wojty1
Advocate Advocate
803 Views
10 Replies
Message 1 of 11

Is it possible to hide all objects within a specific Z-range?

Wojty1
Advocate
Advocate

Hi everyone, 

 

is it possible to hide (all) objects that are within a specific Z-range?

Something like WIPEOUT but only for objects with Z-coordinates within a specified range. 

I have a railway track where a road is passing underneath and to be able to manipulate objects more comfortably I'd like to hide the railway crossing say everything (lines, polys, 3D polys, Splines, block references, etc.) from elevation Z= 120 m to Z=130 m.

Like a void box. 

 

Is there anything I can do to achieve this? 

 

Best regards 

Windows 10 Pro 64-bit | Civil 3D 2024+2025 / Revit 2024 (64-bit EN)
Intel Core i7-7700K / 2x 27" / 64 GB RAM / GeForce RTX 3060 OC V2

Windows 11 Pro 64-bit | All Autodesk Products 2023 - 2025
Intel Core i7-13850HX / 3x 27" / 128 GB RAM / nVidia RTX Ada 3500
0 Likes
804 Views
10 Replies
Replies (10)
Message 2 of 11

nkiakas
Advisor
Advisor

Hi @Wojty1 

 

I did not try this before, but it could be a Dynamo For C3d workflow

 

Regards

0 Likes
Message 3 of 11

AllenJessup
Mentor
Mentor

The DView command might do it for you. Where the clipping planes are set depends on the view direction. You can set a Camera position and a Target.

 

AllenJessup_0-1742305210183.png

 

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 4 of 11

CodeDing
Advisor
Advisor

*ignore*

0 Likes
Message 5 of 11

Wojty1
Advocate
Advocate

Hello @AllenJessup 

I tried DVIEW and played around with the settings, but this doesn't seem to be the right thing since I am working in 3D (all directions) and not just in the XY-Plane (as you may see in the attached screenshot of the project).

The second clip shows a boundary of what I would like to "disappear" in all views and positions, but only the "upper" geometry, not those other objects.

 

Is this somehow possible?
Best regards

Wojty1_0-1742419621639.png

Wojty1_3-1742420073507.png

Wojty1_1-1742419822576.png

 

 

Windows 10 Pro 64-bit | Civil 3D 2024+2025 / Revit 2024 (64-bit EN)
Intel Core i7-7700K / 2x 27" / 64 GB RAM / GeForce RTX 3060 OC V2

Windows 11 Pro 64-bit | All Autodesk Products 2023 - 2025
Intel Core i7-13850HX / 3x 27" / 128 GB RAM / nVidia RTX Ada 3500
0 Likes
Message 6 of 11

AllenJessup
Mentor
Mentor

@Wojty1 

I'm sorry it didn't work for you. It was my best guess. But, I haven't use those functions in DView in a long time.

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 7 of 11

cwr-pae
Mentor
Mentor

It looks to me that you need to put everything you want off on one layer and freeze that layer. All 3D objects can have their appearance controlled by styles and place on the layer to be frozen, everything else would need to be xref'd or in blocks placed on the layer to be frozen.

0 Likes
Message 8 of 11

cwr-pae
Mentor
Mentor

oops should be a rely to @Wojty1 not @nkiakas.

0 Likes
Message 9 of 11

krzysztof.psujek
Advocate
Advocate

Hi, yes it is possible you can try this LISP - it generally works, but you need to remember that the specified range of Z coordinates must cover the entire object.

It is not possible to hide a part of the object, only the whole thing.

;; psujek.krzysztof@gmail.com
;; Hide Objects by Z Range
;; Command: HideByZRange
;; Created: 2024-03-21
;; Description: Hides all objects that fall within a specified Z-coordinate range.
;; Usage: Type HideByZRange in the command line and specify the Z range.

(defun c:HideByZRange (/ zStart zEnd ss ssOut idx enm obj llp urp minZ maxZ temp)
  ;; Get user input for Z range
  (setq zStart (getreal "\nEnter the starting Z coordinate: ")
        zEnd   (getreal "\nEnter the ending Z coordinate: "))
  ;; Ensure zStart is less than zEnd
  (if (> zStart zEnd)
      (setq temp zStart
            zStart zEnd
            zEnd temp))
  
  ;; Get all objects in the drawing
  (if (setq ss (ssget "_X"))
      (progn
        ;; Create selection set based on the specified Z range
        (setq ssOut (ssadd))
        (setq idx 0)
        (while (< idx (sslength ss))
          (setq enm (ssname ss idx))
          (setq obj (vlax-ename->vla-object enm))
          (setq idx (1+ idx))
          
          ;; Check if object supports bounding box
          (if (and (vlax-method-applicable-p obj 'GetBoundingBox)
                   (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))))
              (progn
                (setq minZ (caddr (vlax-safearray->list llp)))  ; Get minimum Z
                (setq maxZ (caddr (vlax-safearray->list urp)))  ; Get maximum Z
                (if (and (<= zStart minZ) (>= zEnd maxZ))  ; Check if object is within the Z range
                    (ssadd enm ssOut)))))
        
        ;; Hide objects if found
        (if (> (sslength ssOut) 0)
            (progn
              (command "_.HIDEOBJECTS" ssOut "")
              (princ (strcat "\nObjects within Z range [" (rtos zStart 2 2) ", " (rtos zEnd 2 2) "] have been hidden.")))
            (princ "\nNo objects found within the specified Z range."))))
  (princ))

 

Message 10 of 11

Wojty1
Advocate
Advocate

Hi @krzysztof.psujek and many thanks for your code.

I have analyzed the LISP routine and tested it on a drawing, but noticed a strange behavior afterwards, especially with the View Cube and related view settings:

All stopped working! Nothing on the View Cube is clickable anymore, well clicking actually is possible, but with no result.

 

Besides that, your LISP routine only hides objects that are located completely within the defined Z-Range, right?

Would it also be possible to create something like a "clipping box" or "3D-Wipeout" which would virtually 'break' objects at its bounding planes?

 

Best regards

Windows 10 Pro 64-bit | Civil 3D 2024+2025 / Revit 2024 (64-bit EN)
Intel Core i7-7700K / 2x 27" / 64 GB RAM / GeForce RTX 3060 OC V2

Windows 11 Pro 64-bit | All Autodesk Products 2023 - 2025
Intel Core i7-13850HX / 3x 27" / 128 GB RAM / nVidia RTX Ada 3500
0 Likes
Message 11 of 11

krzysztof.psujek
Advocate
Advocate

 

Hi,

It is not possible to hide parts of objects; that’s not how it works in AutoCAD/Civil.
Perhaps some tricks could be attempted, but it’s likely a very complex process with many factors and types of objects to consider.

As for the Navicube issue, I don’t think it’s a result of this Lisp. I’ve been experiencing this effect for a while, even without using that specific Lisp, which is why I don’t use it much.


If you want to limit the number of objects being processed from all the objects in the model to only those you select, you can modify lines 18 and 19 in the code above:

 
;; Get all objects in the drawing 
(if (setq ss (ssget "_X"))

to:

 
;; Select objects to proceed with
(princ "\nSelect objects to proceed with: ")
(setq ss (ssget))
(if ss(princ "\nSelect objects to proceed with: ")
(setq ss (ssget))
(if ss
 

Leave the rest code unchanged. It will then behave something like this:

HideByZRange.gif

 

Hope this will help you.

 

0 Likes