Author Topic: Walk or fly through 3d Model, sections in different levels  (Read 2836 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
Walk or fly through 3d Model, sections in different levels
« on: November 11, 2006, 02:07:37 PM »
Hello there,

for the first time we got here a steel structure in 3D to coordinate our ducts and pipes with it. I wonder if somebody has a routine that a: allows you to view in "limited sections" as example from te 3nd floor down to the 2nd.

b: to walk, fly through the building..

Thanks in advance,

Bernd


Amsterdammed

  • Guest
Re: Walk or fly through 3d Model, sections in different levels
« Reply #2 on: November 11, 2006, 05:15:46 PM »
Randy

Since i work in Metric and need the clips in Mspace only i made some changes to your code, the in put is now in 2 points only for Start and Endpoint, the orientation is know then. so i can also go vertical, lets say pt1 is somewhere and pt2 = @0,0,-5000 (we are metric over here so 5000 = 16.4ft) will give me the steel for one level of the building.


Code: [Select]
 

;------------------------------------------------------------------
; original from CADaver with help from Mark Thomas
; modifications and viewport change function by ruul morawetz
; requires UNDO on
; v0.4 last edit 03/11/24
;------------------------------------------------------------------
(setq *dvsdeep* 12.0) ; default section depth
;------------------------------------------------------------------
(defun c:dvs ( / *error*)

   (defun *error* (msg)
      (cond
         (msg (command)(command)(princ (strcat "\nError: " msg)))
         (T nil)
      )
      (dvs:restore)
      (if msg (command "_u"))
   )
   (defun dvs:save ( / n)
      (setq *dvs* nil)
      (command "_undo" "_begin")
      (foreach n '("CMDECHO" "WORLDVIEW" "UCSFOLLOW" "EXPERT")
         (setq *dvs* (cons (cons n (getvar n)) *dvs*))
      )
   )
   (defun dvs:restore ()
      (foreach n *dvs*
         (setvar (car n) (cdr n))
      )
      (command "_undo" "_end")
   )
   (dvs:save)
   (if (not *dvsdeep*) (setq *dvsdeep* 12.0))
   (dvs:section)
   (*error* nil)
   (prin1)
)
;------------------------------------------------------------------
(defun dvs:section (/ pt1 pt2 ang Ndvsdeep)
   (setvar "EXPERT" 5)
   (setq curvp (getvar "cvport"))
   (command "_ucs" "_s" "__TMP")
   (command "_ucs" "_v")
   (cond
      ((null (setq pt1 (getpoint "\nSelect Centerpoint of Section: "))))
      ((null (setq pt2 (getpoint pt1 "\nEnter Viewing Point 2 from Section: ")
                    ang (angle pt1 pt2 )
                   *dvsdeep* (distance pt1 pt2))))
   

      (T
         ;(command "_.undo" "_begin") ; moved to calling function
         (setq pt1 (trans pt1 1 0) pt2 (trans pt2 1 0))
;        (command "_ucs" "_w") ; moved down

;;;         (prompt "\n Select Viewport for Section Display (ENTER if necessary then) ")
;;;         (dvs:rm:cvpc)     ; vp-change function (possibly unreliable)
;;;         ;(getstring)  ; simple and works
;;;
;;;         (setvar "WORLDVIEW" 1)
;;;         (setvar "UCSFOLLOW" 0)
;;;         (command "_ucs" "_w") ; moved here (only necessary after viewport change)
         (command "_.dview" "" "_po" "_non" pt1 "_non" pt2 "_cl" "_f" (* *dvsdeep* 1)  "")
;;;         (command "_.zoom" "_e" "_.zoom" ".8x")
         (setvar "cvport" curvp)
         (command "_ucs" "_r" "__TMP" "_ucs" "_d" "__TMP")
      )
   )
)
;------------------------------------------------------------------
; ruul 03/11/11 - Crazy ViewPort Change
; adjust trigger if needed
; endless loop until clicked in another viewport
; if trigger isn't sufficient, enter also breaks the loop
(defun dvs:rm:cvpc ( / grrd weida p pold viewsize trigger)
   (setq weida T viewsize (getvar "VIEWSIZE")
         trigger (* viewsize 0.4)) ; adjust factor according to mouse speed etc
   (while weida
      (setq grrd (grread T )) ;(+ 1 2 4 8) 2
      (cond
         ((= 5 (car grrd))
            (setq p (cadr grrd))
            (cond
               ((and pold (> (distance p pold) trigger))
                  (setq weida nil)
               )
            )
            (setq pold p)
         )
         ((= 2 (car grrd))(setq weida nil))
         (T nil
         )
      )
   )
)
;------------------------------------------------------------------
(princ  "\nDVSection loaded. call with DVS. ")
;------------------------------------------------------------------
(prin1)
;------------------------------------------------------------------



Thanks a lot

Bernd

CADaver

  • Guest
Re: Walk or fly through 3d Model, sections in different levels
« Reply #3 on: November 13, 2006, 12:46:35 PM »
Pick the point in an elevation view, the routine works just as well in either space with multiple viewports.

Here is one modified for 2 point selection, note the game played with UCS View.  Also a little viewport swapping exercise that fell out of exploring how to toggle viewports (VPSWAP)

Warning, none of this has the least bit of error trapping... well a little.
Code: [Select]
;;-------------------------------------------------------
;; DVIEW Clipping aid
;; original from Falcon Design Services with help from Mark Thomas
;; modifications and wierd little viewport change function by ruul morawetz
;;-------------------------------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vl-load-com)
(vl-load-reactors)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:dvpmk ( / *error*)
   (defun *error* (msg)
      (cond
         (msg (command)(command)(princ (strcat "\nError: " msg)))
         (T nil)
      )
      (dvt:restore)
      (if msg (command "_u"))
   )
   (dvt:save)
   (dvp:sectiontop)
   (*error* nil)
      (prin1)
)
;------------------------------------------------------------------
(defun dvp:sectiontop ();/ ptfrt pt2 ang Ndvpdeep)
   (setvar "EXPERT" 5)
   (setvar "CMDECHO" 0)
   (setvar "orthomode" 1)
   (setq curvp (getvar "cvport"))
   (command "_ucs" "_s" "__TMP")
   (command "_ucs" "_v")
   (cond
      ((null (setq ptfrt (getpoint "\nSelect Front Clipping Plane of Section: "))))
      ((null (setq ptbck (getpoint "\n Select Back Clipping Plane of Section: " ptfrt))))
      ((null (setq ang (angle ptbck ptfrt))))
      ((null (setq dist (distance ptbck ptfrt))))
       (T
         (setq ptfrt (trans ptfrt 1 0) ptbck (trans ptbck 1 0));;;;;;; pt2 (trans pt2 1 0))
         (prompt "\n Select Viewport for Section Display (ENTER if necessary then) ")
         (dvt:rm:cvpc)     ; vp-change function (possibly unreliable)
         (setvar "WORLDVIEW" 1)
         (setvar "UCSFOLLOW" 0)
         (command "_ucs" "_w") ; moved here (only necessary after viewport change)
         (command "_.dview" "" "_po" "_non" ptbck "_non" ptfrt "_cl" "_f" dist "_cl" "_b" "0" "")
         (command "_.zoom" "_e" "_.zoom" ".8x")
         (command "_ucs" "_r" "__TMP" "_ucs" "_d" "__TMP")
      )
   )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;------------------------------------------------------------------
(defun dvt:rm:cvpc ( / grrd weida p pold viewsize trigger)
   (setq weida T viewsize (getvar "VIEWSIZE")
         trigger (* viewsize 0.4)) ; adjust factor according to mouse speed etc
   (while weida
      (setq grrd (grread T )) ;(+ 1 2 4 8) 2
      (cond
         ((= 5 (car grrd))
            (setq p (cadr grrd))
            (cond
               ((and pold (> (distance p pold) trigger))
                  (setq weida nil)
               )
            )
            (setq pold p)
         )
         ((= 2 (car grrd))(setq weida nil))
         (T nil
         )
      )
   )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (defun dvt:save ( / n)
      (setq *dvt* nil)
      (command "_undo" "_begin")
      (setvar "osmode" 0)
      (foreach n '("CMDECHO" "NOMUTT" "CMDECHO" "WORLDVIEW" "UCSFOLLOW" "EXPERT")
         (setq *dvt* (cons (cons n (getvar n)) *dvt*))
      )
   )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (defun dvt:restore ()
      (foreach n *dvt*
         (setvar (car n) (cdr n))
      )
      (command "_undo" "_end")
   )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:dvp ()
(c:dvpmk)
(setvar "cvport" curvp)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:VPSwap ()
(command ".undo" "BEGIN")
(if
  (= (getvar "cvport") 1)
   (command "_mspace")
)
(command "_view" "_d" "vpswap*")            ;;;;Delete any existing vport views

(prompt "\nSelect a DIFFERENT viewport")    ;;;;Get the first viewport
(dvt:rm:cvpc)                               ;;;;Viewport select tool;; subroutine below
(setq vprt01 (getvar "cvport"))             ;;;;Get viewport setvar
(command "_view" "_S" "vpswap01")           ;;;;Save the view of that viewport

(prompt "\nSelect another viewport")        ;;;;Get the second viewport
(dvt:rm:cvpc)                               ;;;;Viewport select tool;; subroutine below
(setq vprt02 (getvar "cvport"))             ;;;;Get viewport setvar
(command "_view" "_S" "vpswap02")           ;;;;Save the view of that viewport

(setvar "cvport" vprt01)                    ;;;;Set first viewport
(command "_view" "r" "vpswap02")            ;;;;Restore Second View

(setvar "cvport" vprt02)                    ;;;;Set second viewport
(command "_view" "r" "vpswap01")            ;;;;Restore first View

(command "_view" "_d" "vpswap*")            ;;;;Delete any existing vport views
(command ".undo" "END")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
« Last Edit: November 13, 2006, 12:56:32 PM by CADaver »

CADaver

  • Guest
Re: Walk or fly through 3d Model, sections in different levels
« Reply #4 on: November 13, 2006, 04:39:20 PM »
I'm still hoping for some LISPy or VBA guru to make a real slick replacement for this.

Amsterdammed

  • Guest
Re: Walk or fly through 3d Model, sections in different levels
« Reply #5 on: November 14, 2006, 04:01:57 AM »
Thanks Randy, :-)

that's fine, the clipping (most importand to see the trees in that wood of steel beams I'm dealing with here) works great.

Any idea if there are some slick lisps around for walking through the building?

Thanks Bernd

Didge

  • Bull Frog
  • Posts: 211
Re: Walk or fly through 3d Model, sections in different levels
« Reply #6 on: November 14, 2006, 04:57:18 AM »
Quote
b: to walk, fly through the building..

This might help:

http://www.theswamp.org/index.php?topic=8775.0
Think Slow......

Amsterdammed

  • Guest
Re: Walk or fly through 3d Model, sections in different levels
« Reply #7 on: November 16, 2006, 11:56:49 AM »
 :laugh:Thanks Didge