Author Topic: Civil3D - Zoom to Structure Command?  (Read 2545 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Civil3D - Zoom to Structure Command?
« on: February 27, 2014, 08:20:17 AM »
Does anyone know what the Zoom to Structure command is? (Rather than opening the toolspace etc)?

Thanks guys!
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil3D - Zoom to Structure Command?
« Reply #1 on: February 27, 2014, 09:13:06 AM »
There is no command for this. It's done with programming when selecting that option in Prospector. A small lisp could likely be written to do this, though.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Civil3D - Zoom to Structure Command?
« Reply #2 on: February 27, 2014, 09:13:58 AM »
I was looking at possibly adding this in a VBA Excel (using sendkeys).
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil3D - Zoom to Structure Command?
« Reply #3 on: February 27, 2014, 09:51:51 AM »
Do you have the Position of the structure in Excel? If so, you could use the normal Autocad Zoom Center command and pass the X & Y values to it. Here is a quickly written lisp that will do this within C3D, user must enter the name of the structure. Command name is zm2struc

Code - Auto/Visual Lisp: [Select]
  1. (defun c:zm2struc (/ *ACAD* C3D C3DDOC LOCATION NTWRK NTWRKS PROD PRODSTR PT STRC STRCNAME STRUCTURES)
  2.   (setq prodStr (strcat "AeccXUiPipe.AeccPipeApplication"
  3.                         (cond ((vl-string-search "\\R17.0\\" prod)
  4.                                ".4.0"
  5.                               )
  6.                               ;;2007
  7.                               ((vl-string-search "\\R17.1\\" prod)
  8.                                ".5.0"
  9.                               )
  10.                               ;;2008
  11.                               ((vl-string-search "\\R17.2\\" prod)
  12.                                ".6.0"
  13.                               )
  14.                               ;;2009
  15.                               ((vl-string-search "\\R18.0\\" prod)
  16.                                ".7.0"
  17.                               )
  18.                               ;;2010
  19.                               ((vl-string-search "\\R18.1\\" prod)
  20.                                ".8.0"
  21.                               )
  22.                               ;;2011
  23.                               ((vl-string-search "\\R18.2\\" prod)
  24.                                ".9.0"
  25.                               )
  26.                               ;;2012
  27.                               ((vl-string-search "\\R19.0\\" prod)
  28.                                ".10.0"
  29.                               )
  30.                               ;;2013
  31.                               ((vl-string-search "\\R19.1\\" prod)
  32.                                ".10.3"
  33.                               )
  34.                               ;;2014
  35.                               (t "")
  36.                         )
  37.                 )
  38.   )
  39.            (setq C3D (vla-getinterfaceobject *acad* prodStr))
  40.            (setq C3Ddoc (vla-get-activedocument C3D))
  41.       )
  42.     (progn
  43.       (setq ntwrks (vlax-get c3ddoc 'pipenetworks))
  44.       (setq strcname (getstring "\nStructure name to zoom to: " t))
  45.       (vlax-for ntwrk ntwrks
  46.         (if (not strc)
  47.           (progn
  48.             (vl-catch-all-apply '(lambda ()
  49.             (setq structures (vlax-get ntwrk 'structures))
  50.             (setq strc (vlax-invoke structures 'item strcname))
  51.                                    )
  52.               '())
  53.           )
  54.         )
  55.       )
  56.       (if strc
  57.         (progn
  58.           (setq location (vlax-get strc 'position))
  59.           (setq pt (list (vlax-get location 'x) (vlax-get location 'y)))
  60.           (command "zoom" "c" pt "")
  61.         )
  62.         (progn
  63.           (princ (strcat "\nStructure \"" strcname "\" not found."))
  64.         )
  65.       )
  66.     )
  67.   )
  68.   (princ)
  69. )
  70.  
  71.  

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Civil3D - Zoom to Structure Command?
« Reply #4 on: February 27, 2014, 10:40:20 AM »
Way cool. Is there a way to place a zoom factor in? (If I am zoomed out / it centers the screen on the structure. If I zoom in closer it zooms right to it.
Again. WAY COOL. Thank you!

Code: [Select]
(defun c:zm2st (/ *ACAD* C3D C3DDOC LOCATION NTWRK NTWRKS PROD PRODSTR PT STRC STRCNAME STRUCTURES)
(vl-load-com)
(setq prod (vlax-product-key))
(setq prodStr (strcat "AeccXUiPipe.AeccPipeApplication"
(cond ((vl-string-search "\\R17.0\\" prod)
       ".4.0"
      )
      ;;2007
      ((vl-string-search "\\R17.1\\" prod)
       ".5.0"

      )

      ;;2008

      ((vl-string-search "\\R17.2\\" prod)

       ".6.0"
      )

      ;;2009

      ((vl-string-search "\\R18.0\\" prod)

       ".7.0"
      )

      ;;2010

      ((vl-string-search "\\R18.1\\" prod)

       ".8.0"

      )

      ;;2011

      ((vl-string-search "\\R18.2\\" prod)

       ".9.0"
      )

      ;;2012

      ((vl-string-search "\\R19.0\\" prod)
       ".10.0"

      )

      ;;2013

      ((vl-string-search "\\R19.1\\" prod)

       ".10.3"

      )

      ;;2014
      (t "")

)

)

  )

  (if (and (setq *acad* (vlax-get-acad-object))

   (setq C3D (vla-getinterfaceobject *acad* prodStr))

   (setq C3Ddoc (vla-get-activedocument C3D))

      )

    (progn

      (setq ntwrks (vlax-get c3ddoc 'pipenetworks))

      (setq strcname (getstring "\nStructure name to zoom to: " t))

      (vlax-for ntwrk ntwrks

(if (not strc)

  (progn

    (vl-catch-all-apply '(lambda ()

    (setq structures (vlax-get ntwrk 'structures))

    (setq strc (vlax-invoke structures 'item strcname))

   )
      '())

  )

)

      )

      (if strc

(progn

  (setq location (vlax-get strc 'position))

  (setq pt (list (vlax-get location 'x) (vlax-get location 'y)))

(command "zoom" "c" pt "")

)

(progn

  (princ (strcat "\nStructure \"" strcname "\" not found."))

)

      )

    )

  )

  (princ)

)
 

 

Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil3D - Zoom to Structure Command?
« Reply #5 on: February 27, 2014, 10:46:07 AM »
To set a scale factor, replace the empty "" in this line:
(command "zoom" "c" pt "")
with your desired factor. Or, remove the "" entirely and it will prompt you for the scale factor.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Civil3D - Zoom to Structure Command?
« Reply #6 on: February 27, 2014, 10:55:07 AM »
sweet! Thank you again!
Civil3D 2020