Jump to content

Pipe Network Check


broncos15
 Share

Recommended Posts

I have never before coded in .net before, but I think I might need to venture into it for something I am trying to accomplish. I want to be able to have a command that would check pipe network, and if the inverts in and inverts out for null structures (I will probably add in another structure as well) where not equal, then put them on another layer. The reason I have tried to accomplish this using LISP, but I can't find any information from a vlax-dump that gives this information, so I think it is impossible. What would the best language to accomplish this be? VBA, .net, or something different? Also, what would be a good starting point to look at?

Link to comment
Share on other sites

.NET development is not something one can usually pick up, without a substantial commitment of time to code, do a lot of reading, more coding, visiting the forums when you get stuck (and you will), and then there's also a lot more coding, of course... Unless you're already adept in another higher language.

 

What slows most new AutoCAD .NET developers down, is thinking that what you already know about LISP/VBA somehow applies, and it very much does not (beyond common sense logic, which should apply to any API)... There is .NET development, and then there is AutoCAD .NET development, on which Civil 3D has it's own subsequent arena... If you want to save yourself some time, first become adept at .NET development outside of AutoCAD, and then come back to it having already learned the fundamentals.

 

Once you've established the fundamentals, coming back is as easy as learning an Object Model, and its inherent Objects, Properties, Methods, and Events (i.e., like learning the vocabulary of a second romance language).

 

 

 

Here's an old thread that may help you get started with .NET generally:

 

 

 

... When you're ready for more specific to Civil 3D, visit my friend Jeff's site, where you'll find some sample source code to learn from:

 

 

 

Speaking of SincPac, your original request above, sounds a lot like SincPac's PIPEELEVATIONEDITOR Command.

 

 

 

 

Disclaimer: I am under NDA with Quux to work on SincPac, so I am completely, and utterly biased. :thumbsup:

 

 

 

Cheers

Link to comment
Share on other sites

Thanks BlackBox for the tips and suggestions! I know that I need to start learning .NET seeing as I primarily do coding for Civil 3D. Those resources in the other thread are very useful, thank you for posting! I have done VBA programming in Excel before, so I am hoping that at least some of the logic/syntax is similar for vb.net.

Link to comment
Share on other sites

Blackbox, I was curious if you would happen to know if there is a way to access the invert elevations of connected pipes through LISP. I know that AutoCAD has some hidden functions and properties that aren't revealed from a vlax-dump, but I wasn't sure if this was one of them (also, do you know a good source for these hidden functions?)

Link to comment
Share on other sites

  • 3 months later...

I realize that this post is a little old and maybe you had found your answer.

 

To obtain the the start and end points of a pipe you need to use the following:

 

Let 'obj' be the pipe object.

(setq startpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'PointAtParam 0)))) 'CenterPoint of Start of Pipe
(setq endpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'PointAtParam 1)))) 'CenterPoint of End of Pipe

Link to comment
Share on other sites

I realize that this post is a little old and maybe you had found your answer.

 

To obtain the the start and end points of a pipe you need to use the following:

 

Let 'obj' be the pipe object.

(setq startpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'PointAtParam 0)))) 'CenterPoint of Start of Pipe
(setq endpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'PointAtParam 1)))) 'CenterPoint of End of Pipe

Hippe, thank you so much for the help. This code has been one I have been banging my head on for a while. The problems that I have come across so far is 1)I can't figure out what to do after I have the start points and endpoints. How do I test which one is the one actually at the structure? 2) I would ideally want to expand this code out even more so that the user would be prompted to select a structure type and enter in the desired drop. The code would then test all the manholes for example to see if they have a 0.2' drop. This seems like it would make the code even more complex and I end up feeling lost in repeat loops haha.
;;;Finding the startpoint and endpoint of the pipes was written by Hippe013
(defun c:invertdroptester (/ ss cnt obj pipename)
 (if (setq ss (ssget "_X" '((0 . "AECC_STRUCTURE"))))
   (progn
     (setq cnt 0)
     (repeat (sslength ss)
       (setq structureobj (vlax-ename->vla-object (ssname ss cnt)))
       (if (and (> (vlax-get-property structureobj 'connectedpipescount) 0)
                (= (vla-get-description structureobj) "Null Structure")
         (progn
           (setq pipename (vlax-get-property structureobj 'connectedpipenames))
           (setq ss1 (ssget "_X" '((0 . "AECC_STRUCTURE")))
                 cnt1 0)
           (repeat (sslength ss1)
             (setq pipeobj (vlax-ename->vla-object (ssname ss1 cnt1)))
             (if (= (vlax-get-property pipeobj 'displayname) pipename)
               (progn
                 ;;;Starting of code written by Hippe013
                 (setq startpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property pipeobj 'PointAtParam 0)))) ;CenterPoint of Start of Pipe
                 (setq endpoint (vlax-safearray->list (vlax-variant-value (vlax-get-property pipeobj 'PointAtParam 1)))) ;CenterPoint of End of Pipe

Link to comment
Share on other sites

Bronco15,

 

This is rather funny as I have already written a piece of code to do just what you are asking. Though to answer your question:

 

1) Once you have the start and end points you could test to see which point is closer to the center of the structure. I would use only XY for this.

 

2) This may be a bit more complex as you would need to know which one stays and which one gets adjusted. Let us say the that the structure has only two connecte pipes (in and out). Do you hold the lowest invert and adjust the other 0.2 above the other or do you hold the inflow pipe and adjust the other 0.2 down.

 

I have some subroutines that I am willing to share. Mind you that they are in LISP and not in vb.net.

 

Let me know if you are interested.

 

regards,

 

Ben

Link to comment
Share on other sites

Bronco15,

 

This is rather funny as I have already written a piece of code to do just what you are asking. Though to answer your question:

 

1) Once you have the start and end points you could test to see which point is closer to the center of the structure. I would use only XY for this.

 

2) This may be a bit more complex as you would need to know which one stays and which one gets adjusted. Let us say the that the structure has only two connecte pipes (in and out). Do you hold the lowest invert and adjust the other 0.2 above the other or do you hold the inflow pipe and adjust the other 0.2 down.

 

I have some subroutines that I am willing to share. Mind you that they are in LISP and not in vb.net.

 

Let me know if you are interested.

 

regards,

 

Ben

Ben, thank you so much for your willingness to help. I would really appreciate it if you shared your code. I am having a very difficult time finding even basic information like the structure insertion point because of how the information is given. So the goal of this code at least is to not actually change any of the pipe's inverts, but rather to just check that all the inverts meet the required drop.
Link to comment
Share on other sites

What you are looking at doing seems rather reasonable. I'll write up a test code over the weekend.
Wow, thank you! I would love to have some example code for pipe networks, especially for a great starting point for future code with them.
Link to comment
Share on other sites

Broncos15,

 

Below is some example code for getting a structures connected pipes and listing the inverts. Should we start a new thread in the visual lisp section for listing lisp code for pipes and structures?

 

(defun C:PrintStructure ()
 (setq ss (selectstructure))
 (setq struct (vlax-ename->vla-object (ssname ss 0)))
 (princ (strcat "\n" (vlax-get-property struct 'DisplayName) " - Sump Elevation: "
	 (rtos (vlax-get-property struct 'SumpElevation) 2 2)))
 (setq cnt (vlax-get-property obj 'ConnectedPipesCount))
 (setq i 0)
 (repeat cnt
   (setq pipe (vlax-get-property struct 'ConnectedPipe i))
   (setq end (getend struct pipe))
   (setq dia (vlax-get-property pipe 'InnerDiameterOrWidth))
   (setq p (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam end))))
   (setq inv (- (caddr p) (/ dia 2.0)))
   (princ (strcat "\n" (vlax-get-property pipe 'DisplayName) " - Invert: " (rtos inv 2 2)))
   (setq i (+ i 1))
   )
 (princ)
 )

(defun getend (struct pipe)
 (setq p (vlax-get-property struct 'Position))
 (setq p (list (vlax-get-property p 'X)(vlax-get-property p 'Y)))
 (setq p0 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 0))))
 (setq p1 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 1))))
 (if (< (distance (list (car p0)(cadr p0)) p)
 (distance (list (car p1)(cadr p1)) p))
   0
   1))

(defun selectstructure ()
 (princ "\nSelect Structure: ")
 (setq sel (ssget "_+.:S"  '((0 . "AECC_STRUCTURE"))))
 (if (not sel)
   (progn
     (princ "\nOops, Invalid Selection")
     (selectstructure)))
 sel
 )

Link to comment
Share on other sites

Broncos15,

 

Below is some example code for getting a structures connected pipes and listing the inverts. Should we start a new thread in the visual lisp section for listing lisp code for pipes and structures?

 

(defun C:PrintStructure ()
 (setq ss (selectstructure))
 (setq struct (vlax-ename->vla-object (ssname ss 0)))
 (princ (strcat "\n" (vlax-get-property struct 'DisplayName) " - Sump Elevation: "
        (rtos (vlax-get-property struct 'SumpElevation) 2 2)))
 (setq cnt (vlax-get-property obj 'ConnectedPipesCount))
 (setq i 0)
 (repeat cnt
   (setq pipe (vlax-get-property struct 'ConnectedPipe i))
   (setq end (getend struct pipe))
   (setq dia (vlax-get-property pipe 'InnerDiameterOrWidth))
   (setq p (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam end))))
   (setq inv (- (caddr p) (/ dia 2.0)))
   (princ (strcat "\n" (vlax-get-property pipe 'DisplayName) " - Invert: " (rtos inv 2 2)))
   (setq i (+ i 1))
   )
 (princ)
 )

(defun getend (struct pipe)
 (setq p (vlax-get-property struct 'Position))
 (setq p (list (vlax-get-property p 'X)(vlax-get-property p 'Y)))
 (setq p0 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 0))))
 (setq p1 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 1))))
 (if (< (distance (list (car p0)(cadr p0)) p)
    (distance (list (car p1)(cadr p1)) p))
   0
   1))

(defun selectstructure ()
 (princ "\nSelect Structure: ")
 (setq sel (ssget "_+.:S"  '((0 . "AECC_STRUCTURE"))))
 (if (not sel)
   (progn
     (princ "\nOops, Invalid Selection")
     (selectstructure)))
 sel
 )

Thanks Hippe! I'll start a thread over in LISP with this and the edits that I add. Also, there was a small error in the code,
(setq cnt (vlax-get-property obj 'ConnectedPipesCount))

should be

(setq cnt (vlax-get-property struct 'ConnectedPipesCount))

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
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.

 Share

×
×
  • Create New...