Jump to content

Calculating a Pipe Invert


rcb007

Recommended Posts

I have the following routine I was working on, and I cannot seem to get it to work.

I was using the links below to try to combine the code into a simpler version.

Object was to select a pipe. Ask for start and end invert and then apply it to the pipe.

Using the center points of the pipe, I needed to take the invert and add half the height of the pipe to calculate the centerline.

The centerline value is value that would update the pipe.

 

;;https://forums.autodesk.com/t5/civil-3d-customization/pipe-inverts-lisp/td-p/6284166
;;https://forums.augi.com/showthread.php?154515-find-pipe-inverts-at-arbitrary-locatio

(defun c:changeinverts ( / _myspace _getparam inv0 inv0 cp0 cp1 cl0 cl1 sel ent obj p0 p1 p0a p1a) 
  (defun _myspace (/ adoc space)
    (vl-load-com)
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
    (setq space	(if (= 1 (vla-get-activespace adoc))
		  (vla-get-modelspace adoc)
		  (if (= (vla-get-mspace adoc) :vlax-true)
		    (vla-get-modelspace adoc)
		    (vla-get-paperspace adoc)
		  )
		)
    )
  )
;;;;;;;;;;;;;;;;;;;;;;;;;
  (defun _getparam (obj param)
    (vlax-safearray->list
      (vlax-variant-value
	(vlax-get-property pipe 'pointatparam param)
      )
    )
  )
;;;;;;;;;;;;;;;;;;;;;;;;
  (setq sel (entsel)) ;; Select the pipe
  (setq ent (car sel)) ;; Get the pipe entity name
  (setq obj (vlax-ename->vla-object ent)) ;; Convert pipe to object
  (setq p0     (_getparam obj 0.0)) ;; Get the Pipe Center START POINT
  (setq p1     (_getparam obj 1.0)) ;; Get the Pipe Center END POINT
  (setq height   (vlax-get-property obj 'InnerHeight)) ;;Object Pipe Height
  (setq cp0     (mapcar '- p0 (list 0.0 0.0 (* 0.5 height))))) ;;Calc Half size of pipe at Start
  (setq cp1     (mapcar '- p1 (list 0.0 0.0 (* 0.5 height)))) ;;Calc Half size of pipe at End
  (setq inv0     (getreal "\nEnter Start Invert Line: ")) ;;User Enter Start Invert
  (setq inv1     (getreal "\nEnter Invert Line: ")) ;;User Enter End Invert
  (setq cl0     (/ (+ (inv0) (cp0)) 12.0)))  ;;inv plus half calc pipe size times 12 to equal centerline
  (setq cl1     (/ (+ (inv1) (cp1)) 12.0)))  ;;inv plus half calc pipe size times 12 to equal centerline
  (vlax-invoke-method 
   obj
  'SetStartAndEndPoints
  (vlax-3d-point cl0) ;;Change Start Point to User Centerline
  (vlax-3d-point cl1) ;;Change End Point to User Centerline
  )
(princ))

 

Thank you for the eyes. 

Link to comment
Share on other sites

I think we need a dwg not sure what your doing, any reason for not maybe using pipe design add on ? They are normally interactive with regard setting invert levels, do way more also.

Link to comment
Share on other sites

Sounds good. Below is the original code.

 

;;https://forums.autodesk.com/t5/civil-3d-customization/pipe-inverts-lisp/td-p/6284166
(defun c:TypeInv ( / sel ent obj p0 p1 p0a p1a)
  ; Select the pipe
  (setq sel (entsel))

  ; Get the entity name
  (setq ent (car sel))

  ; Convert to object
  (setq obj (vlax-ename->vla-object ent))
  
  ; Get the Pipe START POINT
  (setq p0 (vlax-safearray->list
             (vlax-variant-value (vlax-get-property obj 'PointAtParam 0))
           )
  )

  ; Get the Pipe END POINT
  (setq p1 (vlax-safearray->list
             (vlax-variant-value (vlax-get-property obj 'PointAtParam 1))
           )
  )

  ; Calculate new START POINT
  ;(setq p0a (list (nth 0 p0) (nth 1 p0) 10.0))
  (setq p0a (list (nth 0 p0) (nth 1 p0) (getreal "\nEnter Start Center Line: ")))

  ; Calculate new END POINT
  ;(setq p1a (list (nth 0 p1) (nth 1 p1) 11.0))
  (setq p1a (list (nth 0 p1) (nth 1 p1) (getreal "\nEnter Center Line: ")))

  ; Make the changes
  (vlax-invoke-method
    obj
    'SetStartAndEndPoints
    (vlax-3d-point p0a)
    (vlax-3d-point p1a)
  )
  
  (princ)
)

 

TypeInv.dwg

Link to comment
Share on other sites

So pick 2 points and imply a Y difference not that hard, just move the 2nd circle up the Y difference even if vertical scale involved then draw 2 offset lines based on the new center points of the circles.

 

Please people no code 

 

Rbc007 you have lots of posts have a go yourself, we can help you more if you help your self 1st. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...