Flat centerline of a plate

Flat centerline of a plate

jotaferrer
Advocate Advocate
1,463 Views
21 Replies
Message 1 of 22

Flat centerline of a plate

jotaferrer
Advocate
Advocate

Here I am again, guys!

 

I need a routine that takes a plate and creates a continuos line based on the centerline of a polyline or its vertex (the easiest option) as you can see in the example bellow. Can someone please help me or at least guide me in the process? Thank you in advance!

 

jotaferrer_0-1634640501156.png

 

0 Likes
Accepted solutions (2)
1,464 Views
21 Replies
Replies (21)
Message 2 of 22

calderg1000
Mentor
Mentor

Regards @jotaferrer 

Hope this helps something.

(defun c:lpl (/ e s lp lt)
  (setq
    spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
  )
  (setq e  (Getreal "\nEnter Plate thickness...:")
        lp (vla-get-length
             (vlax-ename->vla-object (car (entsel "\n Select Plate..:")))
           )
  )
  (setq lt (/ (- lp (* 2 e)) 2))
  (vla-addline spm
               (vlax-3d-point (setq p1 (getpoint "\nEnter Result Location...:")))
               (vlax-3d-point (mapcar '+ p1 (list lt 0 0 0)))
  )
  (princ lt)
  (princ)
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 3 of 22

Sea-Haven
Mentor
Mentor

I am not a folding plate person but does not the min radius affect the true length ?

Message 4 of 22

ВeekeeCZ
Consultant
Consultant

You can try @Kent1Cooper 's unfold... but it does not do a centerline.

 

Message 5 of 22

hak_vz
Advisor
Advisor

@Sea-Haven wrote:

I am not a folding plate person but does not the min radius affect the true length ?


As long as shape is symmetrical to center line result is OK

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 6 of 22

hak_vz
Advisor
Advisor

I guess that better way to create deformed plate element would be to use double offset from center line. First create center line and then offset to both sides and join to single polyline. We have similar request before so searching through older post may bring up something useful. 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 22

jotaferrer
Advocate
Advocate

Thanks for your answer @calderg1000

It works indeed! But is there a way to keep the vertext when the line is drew? If it does, there will be my solution 😅

 

Thank you again!

0 Likes
Message 8 of 22

jotaferrer
Advocate
Advocate

Thank you again @ВeekeeCZ it work well but I need to explode the plate or create the centerline... I'm going to try to fit his code for my needs. Thanks man!

0 Likes
Message 9 of 22

jotaferrer
Advocate
Advocate
Yeah, that's right!
0 Likes
Message 10 of 22

jotaferrer
Advocate
Advocate
That's the way I do too. I'll give another try because I had already searched before. Thanks for you answer!
0 Likes
Message 11 of 22

calderg1000
Mentor
Mentor

Regards @jotaferrer 

If the code helps in your case I am very happy. Although because of the language, I do not interpret very well what you request, additionally I try to understand that you want the result with an automatic grip point. Here I made a little change.

(defun c:lpl2 (/ spm e s lp lt p1)
  (setq
    spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
  )
  (setq e  (Getreal "\nEnter Plate thickness...:")
        s  (vlax-ename->vla-object (car (entsel "\n Select Plate..:")))
        lp (vla-get-length s)
  )
  (setq lt (/ (- lp (* 2 e)) 2))
  (vla-addline spm
               (vlax-3d-point (setq p1 (vlax-curve-getStartPoint s)))
               (vlax-3d-point (mapcar '+ p1 (list lt 0 0 0)))
  )
  (princ lt)
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 12 of 22

jotaferrer
Advocate
Advocate
Thanks for your fast answer! But it didn't change, sadly...
Can you do something like the Kent1Cooper did in the lisp posted above? I liked your way to "get the plate" but I need something like he did. When the straight plate is drew, I'd like to draw a polyline with the grips where it changes its direction.

I can explain it better in the chat in your language though.
0 Likes
Message 13 of 22

leeminardi
Mentor
Mentor

@hak_vz wrote:

@Sea-Haven wrote:

I am not a folding plate person but does not the min radius affect the true length ?


As long as shape is symmetrical to center line result is OK


Not necessarily, to be precise the bend allowance should be considered.

lee.minardi
Message 14 of 22

jotaferrer
Advocate
Advocate

I think a print screen would do a better explanation...

 

1-Select the plate (closed polyline)

2-Create a centerline with radius zero

3-Draw a polyline with the segments lengths based on centerline

 

jotaferrer_0-1634734536498.png

 

0 Likes
Message 15 of 22

Kent1Cooper
Consultant
Consultant

@jotaferrer wrote:
....
Can you do something like the Kent1Cooper did in the lisp posted above? I liked your way to "get the plate" but I need something like he did. When the straight plate is drew, I'd like to draw a polyline with the grips where it changes its direction.
....

[>Here< is the source of that routine with its original command name and context, in case you're interested.]

 

Manually, assuming the profile is a single closed Polyline, I would suggest TRIMming away the short end segments, OFFSETting one of the resulting two Polylines to halfway between the two for a center-line path, and using the SPS command [under whatever name] on that.

 

To automate that could be a challenge, depending on certain things:

 

Does the Polyline always start at one of the ends?  If so, is the first segment always the short end one, or always the one extending from there along the length of the profile, or might the starting point be anywhere?

 

Are they always Z-shaped [i.e. two and only two bends], or might they sometimes be L-shaped [one bend] or have more than two bends?

Kent Cooper, AIA
Message 16 of 22

Kent1Cooper
Consultant
Consultant

@jotaferrer wrote:

I think a print screen would do a better explanation...

....


So now that I see your image, I just want to clarify:  You don't want a result like this?

Kent1Cooper_0-1634735467143.png

If that's the case, the manual approach I suggested before would need to include FILLETing the center-path Polyline with Zero radius before SPSing it.  But I think the same questions would apply.

Kent Cooper, AIA
Message 17 of 22

jotaferrer
Advocate
Advocate
Thanks for you answer @Kent1Cooper !
For sure I'm interested in your source code. As long as I'm still a toddler when it comes to lisps, I'm like studying every single code I can hehe

About the Polyline ends: the first segment is always the shortest one and there will be more than two bends.

A result like your lisp gives it's perfect, as long as I draw the centerline which is pretty easy to do, but I think it'd be even more perfect if it was automated.
You know the pain to expand a plate, don't you? xD
0 Likes
Message 18 of 22

jotaferrer
Advocate
Advocate
I think it's better to answer you in a single post, buddy
0 Likes
Message 19 of 22

Kent1Cooper
Consultant
Consultant
Accepted solution

@jotaferrer wrote:
....
About the Polyline ends: the first segment is always the shortest one and there will be more than two bends.
A result like your lisp gives it's perfect, as long as I draw the centerline which is pretty easy to do, but I think it'd be even more perfect if it was automated.
....

If that is truly always the case, and if all bends are always radiused, try this [in simplest terms, minimally tested]:

 

(defun C:SPCLS ; = Stretch Polyline CenterLine Straight
  (/ pl1 verts pl2 pl3 lengths)
  (setq
    pl1 (car (entsel "\nSelect bent-plate section profile: "))
    verts (cdr (assoc 90 (entget pl1)))
  ); setq
  (command "_.pedit" pl1 "_edit" "_Break" "_next" "_go")
  (repeat (1- (/ verts 2)) (command "_next")); move around to break at other end
  (command "_break" "_next" "_go" "_exit" "")
  (setq pl2 (entlast))
  (command "_.offset" "_through" pl1 "_m2p" (vlax-curve-getStartPoint pl1) (vlax-curve-getEndPoint pl2) "")
  (setq pl3 (entlast))
  (setvar 'filletrad 0)
  (command "_.fillet" "_polyline" pl3); take out radii at bends
  (repeat (setq par (fix (vlax-curve-getEndParam pl3)))
    (setq lengths ; list of segment lengths
      (cons
        (- ; length of segment ending at parameter
          (vlax-curve-getDistAtParam pl3 par)
          (vlax-curve-getDistAtParam pl3 (setq par (1- par)))
        ); -
        lengths
      ); cons
    ); setq [lengths]
  ); repeat
  (command "_.pline" (getpoint "\nStart of straightened path: "))
  (repeat (length lengths); feed segment lengths out to Pline
    (command "_none" (polar (getvar 'lastpoint) 0 (car lengths)))
    (setq lengths (cdr lengths))
  ); repeat
  (command "")
  (princ)
)

 

Kent Cooper, AIA
0 Likes
Message 20 of 22

ВeekeeCZ
Consultant
Consultant
Accepted solution

Does it matter where it's picked? It does not seem to work well...

 

Since I was thinking of a similar workflow, I made smaller adjustments... which works for me.

 

 

(defun C:SPCLS ; = Stretch Polyline CenterLine Straight
       (/ pl1 pt1 verts pl2 pl3 lengths)
  (setq
    pl1 (entsel "\nSelect bent-plate section profile at thin side: ")
    pt1 (cadr pl1)
    pl1 (car pl1)
    verts (cdr (assoc 90 (entget pl1)))
    ); setq
  (command "_.undo" "_mark")
  (command "_.trim" "" "_non" pt1 "")
  (command "_.pedit" pl1 "_edit")
  (repeat (1- (/ verts 2)) (command "_next")); move around to break at other end
  (command "_break" "_next" "_go" "_exit" "")
  (setq pl2 (entlast))
  (command "_.offset" "_through" pl1 "_m2p" (vlax-curve-getStartPoint pl1) (vlax-curve-getEndPoint pl2) "")
  (setq pl3 (entlast))
  (setvar 'filletrad 0)
  (command "_.fillet" "_polyline" pl3); take out radii at bends
  (repeat (setq par (fix (vlax-curve-getEndParam pl3)))
    (setq lengths ; list of segment lengths
	   (cons
	     (- ; length of segment ending at parameter
	       (vlax-curve-getDistAtParam pl3 par)
	       (vlax-curve-getDistAtParam pl3 (setq par (1- par)))
	       ); -
	     lengths
	     ); cons
	  ); setq [lengths]
    ); repeat
  (command "_.undo" "_b")
  (command "_.pline" (getpoint "\nStart of straightened path: "))
  (repeat (length lengths); feed segment lengths out to Pline
    (command "_none" (polar (getvar 'lastpoint) 0 (car lengths)))
    (setq lengths (cdr lengths))
    ); repeat
  (command "")
  (princ)
  )

 

0 Likes