Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need a Lisp to match pipe inverts

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
saqib_tipa
432 Views, 8 Replies

Need a Lisp to match pipe inverts

Hello all,

I need a Lisp which can match pipe inverts to other pipes. Like Matchprop of Cad command but it will only match Inverts of first selected pipe to other selected pipes.

Thank you.

8 REPLIES 8
Message 2 of 9
NateSarles
in reply to: saqib_tipa

@saqib_tipa, I am not much of a coder, but I would vote for this on the C3D Ideas Forum!

C3D 2025
Sr. CAD Technician
Windows 11, 32 GB RAM
11th Gen Intel(R) Core(TM) i7-11370H
Message 3 of 9
saqib_tipa
in reply to: saqib_tipa

When convenient, could a Lisp expert please assist me with my post?

Thanks.

Message 4 of 9
hippe013
in reply to: saqib_tipa

Can you explain, in detail, the workflow that you imagine? 

Message 5 of 9
saqib_tipa
in reply to: hippe013

@hippe013 ,

Thank you for reply, I need to match pipe Invert levels (start Invert Elevation & End Invert Elevation) to other selected pipes.  Suppose I select pipe 1 so it should store pipe 1 invert levels and then I select pipe 2,3,4 then it should apply pipe 1 Invert levels to pipe 2,3,4. 

Hope you understand.

Thanks.

 


@hippe013 wrote:

Can you explain, in detail, the workflow that you imagine? 


 

Message 6 of 9
hippe013
in reply to: saqib_tipa

From the source pipe, which invert end gets applied to which end of the target pipe? Is that based on user selection, selecting close to start point uses the start versus selecting closer to the end point uses the end invert? 

 

Or is it select source pipe, and its start invert gets applied to the start of the target pipe and the end invert of source pipe gets applied to the end invert of the target pipe? 

Message 7 of 9
saqib_tipa
in reply to: hippe013

@hippe013 

Second one.

'Or is it select source pipe, and its start invert gets applied to the start of the target pipe and the end invert of source pipe gets applied to the end invert of the target pipe'

Thank you.

Message 8 of 9
hippe013
in reply to: saqib_tipa

@saqib_tipa 

 

I do think that with the previous examples that I have shown you that you are capable of writing this one on your own. Below is a quick example of getting a single source pipe and then prompting for a selection set of target pipes. 

 

Then loop through each pipe in the selection set and set its inverts. 

 

 

(defun c:PipeMatchInverts ( / srcSS tarSS)
  (princ "\nSelect Source Pipe: ")
  (setq srcSS (ssget ":s+." '(( 0 . "AECC_PIPE"))))
  (if srcSS
    (progn
      (princ "\nSelect Select Target Pipes:")
      (setq tarSS (ssget '(( 0 . "AECC_PIPE"))))
      (if tarSS
	(progn
	  (setq srcPipe (vlax-ename->vla-object (ssname srcSS 0)))
	  (setq halfDia (/ (vlax-get-property srcPipe 'InnerDiameterOrWidth) 2.0))
	  (setq p0Inv (- (caddr (vlax-safearray->list (vlax-variant-value (vlax-get-property srcPipe 'PointAtParam 0)))) halfdia))
	  (setq p1Inv (- (caddr (vlax-safearray->list (vlax-variant-value (vlax-get-property srcPipe 'PointAtParam 1)))) halfdia))
  	  (setq n 0)
	  (repeat (sslength tarSS)
	    (setq tarPipe (vlax-ename->vla-object (ssname tarSS n)))
	    (P:PipeSetInverts tarPipe p0Inv p1Inv)
	    (setq n (+ n 1))
	    )
	  )
	)
      )
    )
  (princ)
  )


(defun P:PipeSetInverts (pipe startInvert endInvert / p0 p1)
  (setq halfDia (/ (vlax-get-property pipe 'InnerDiameterOrWidth) 2.0))
  (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 startInvert (setq p0 (list (car p0) (cadr p0) (+ startInvert halfDia))))
  (if endInvert (setq p1 (list (car p1) (cadr p1) (+ endInvert halfdia))))
  (vlax-invoke-method pipe 'SetStartAndEndPoints (vlax-3d-point p0)(vlax-3d-point p1))
  )
      

 

 

 

Note, this code does NOT resize the structures after the pipes have been adjusted. I will let you figure how to have the structures resize. 

 

 

Message 9 of 9
saqib_tipa
in reply to: hippe013

@hippe013 

 

Thank you for the reply. Sir believe me I am not able to write Lisp code by my own. It's very difficult for me to write such code. Previous example you are talking about I just tried to figure out but could not. This code looks different from previous code, and I know I cannot do it in the first place.

 

The code you provided now is very nice and working as I want to. I don't need structures to resize at the moment, if needed I will ask for your help again but for now it's enough for me.

 

Thank you so much again for your help. You are amazing.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report