Jump to content

tube bending lisp or??


Jack_O'neill

Recommended Posts

Thanks Bigal and marko_ribar.  If I get a chance after work tonight, I will create and upload some drawings to explain it better.  Unfortunately, today, Monday and Tuesday are the last 3 business days of the month, and that usually translates to a much higher level of insanity at work than normal. So it may be tomorrow or even Sunday before I get to it.

 

Thanks for all your help, and to everyone else that has contributed in any way.

 

Stay healthy my friends.

Link to comment
Share on other sites

Ok...here is what I do manually.  I take a solid like this: image.png.9a51834650e3fa9baec0529d7713f31a.png

This is a solid bar, not a tube.  I have no input on how its created, my customer does this.   He uses Catia.  I go through several  steps to get it to something Autocad can read.  In the end, I'm left with a solid.  The shapes vary wildly.  I then use the shade command to make it a wireframe, thusly:

 

image.png.a30d29011eb9ac57939817d6d91e909c.png

 

I then draw lines center to center on the straight parts of the tube like this (red lines)

image.png.5ed88eaf028c2d7a52e9e627304e5c99.png

 

at this point, the solid no longer matters and can be erased, but that is optional.  The bit that matters is that I zero- fillet these straight lines, thusly:

 

image.png.2fdb467c42a153e67ff2ea756401a927.png

 

At this point, I need to identify the cooridinates of each of the intersections and put that in a table.  For instance, the first end point (pt 1) is obviously 0,0,0.  The next point (pt2) is  X = 1.8430     Y = 0.0000     Z = 0.0000.  

image.thumb.png.c37829d7650478faf2a7bc0b0c23d681.png

and so forth all the way to the end of the tube.

 

This gives me a bend data table similar to this ( and this is not for this part, just an example):

image.png.4247de93d3495b84e637eacf691f3840.png

This data allows me to feed my cnc bender the info it needs to bend the tube.

 

Sometimes my customers give me this bend data table, and the lisp that Roy wrote for me works perfectly to create the models.  A different division of this same company however, sends me the Catia models, and I have to construct this bend data table myself by going through the steps I just detailed.   No choice on how its drawn, all I get is the model.  No dimensions, just the solid model. 

 

So...once again...not looking for a freebee...if someone can and will write a lisp that will do this, assuming its even possible, I will gladly trade an equitable amount of drafting work, in advance, for the lisp.  If it can be done, great.  If it can't, thats ok too.  If you don't want to do it that way, that's fine too, make me an offer.  Maybe we can work something out.  If you don't want to do it at all, that's ok, just ignore this post.  Pass on by, it's all good.

 

Thanks again, and have a great weekend.  

 

Stay healthy my friends.

 

 

 

image.png

Edited by Jack_O'neill
Link to comment
Share on other sites

Hi Jack , may I state that such tubes start and end, always, in a straight tube ??

I'm dealing with your dwg since you start the post .

It is an awkward task . 

Please upload  some other dwg  to check.

 

 

 

 

  

Link to comment
Share on other sites

Hi Jack, if you looked at my attached DWG in my last post, you can see that I interpolated path curve with 3dpoly with more vertices along straight and filleted segments... If you can switch from table you posted to table with just points - you can decide what precision you like per tube segment, then this can be automated... Otherwise with procedure you explained and you are doing, I can't be sure that this is possible in quick way ( it is, but you have to code it even more to achieve this and that takes time...)... If you PM me on ribarm@gmail.com I can give you my method that can be used, but to achieve it your way, the task is then widening to code for intersection points of straight segments from 2 points on one side and 2 points on the other straight side and plus you have to find filleted radius... To me this all complicates things especially when you have points that likely represent correct tube shape... I don't know how machine works, but it is my suggestion for your task - I wanted to help as much as I can... Once again, see if my lastly posted DWG could be used for you to create table you want - if you can create table from my path representation then perfect, but if you can't I can't be of much help... And lastly, you still even with my method have to work with 3d solid tube - you have to firstly convert it to nurbs surfaces, set UV precision of isolines, apply extraction and finally last routine for path generation... When you look deeply this procedure is also time taking and if only you have too large tubes with much bending and much segments, only then it could be said that it's preferable in terms of speeding things...

Regards, and also stay healthy...

M.R.

Link to comment
Share on other sites

 another way to skin the cat, crude and rude.

 

Explode the 3d-solid to surfaces,

As a bended tube shall be, as far as i Know, start and end in a straight tube, and it shall be only one curve between straight tubes.

 

So, try to change to  same  colour each straight , and then  to other color  ech curves

Select straight  by colour , copy ss, and  change to a new layer the copied to a new layer.

Then and in a loop, explode one by one , and get both circles,  get the center , as follow 

Or maybe it can be done in a foreach en from SS-ent-list 

(VL-CMDF "explode" SURFACE-ENT "")

  (SETQ CIRCLES-SS (SSGET "X" '((0 . "circle"))))


  (SETQ CIRCLE-01-ENT (SSNAME CIRCLES-SS 0))
  (SETQ CIRCLE-02-ENT (SSNAME CIRCLES-SS 1))

  (SETQ CIRCLE-01-OBJ (VLAX-ENAME->VLA-OBJECT CIRCLE-01-ENT))
  (SETQ CIRCLE-02-OBJ (VLAX-ENAME->VLA-OBJECT CIRCLE-02-ENT))



  (SETQ CIRCLE-01-ASSOC-10 (CDR (AsSOC 10 (ENTGET CIRCLE-01-ENT))))
  (SETQ CIRCLE-02-ASSOC-10 (CDR (AsSOC 10 (ENTGET CIRCLE-02-ENT))))


  (SETQ CIRCLE-01-ASSOC-210 (CDR (ASOC 210 (ENTGET CIRCLE-01-ENT))))
  (SETQ CIRCLE-02-ASSOC-210 (CDR (ASOC 210 (ENTGET CIRCLE-02-ENT))))

(SETQ CIRCLE-01-OBJ-CENTER-VAR (VLA-GET-CENTER CIRCLE-01-OBJ))
(SETQ CIRCLE-02-OBJ-CENTER-VAR (VLA-GET-CENTER CIRCLE-02-OBJ))

  
(SETQ CIRCLE-01-OBJ-CENTER-SAF (VLAX-VARIANT-VALUE CIRCLE-01-OBJ-CENTER-VAR))
(SETQ CIRCLE-02-OBJ-CENTER-SAF (VLAX-VARIANT-VALUE CIRCLE-02-OBJ-CENTER-VAR))


(SETQ CIRCLE-01-OBJ-CENTER-XYZ (VLAX-SAFEARRAY->LIST CIRCLE-01-OBJ-CENTER-SAF))
(SETQ CIRCLE-02-OBJ-CENTER-XYZ (VLAX-SAFEARRAY->LIST CIRCLE-02-OBJ-CENTER-SAF))


(SETQ LINEA-POR-VL (VLA-ADDLINE MODEL CIRCLE-01-OBJ-CENTER-VAR CIRCLE-02-OBJ-CENTER-VAR))




 

I try to use TRANS to equal bot centers , but it is far away my knowledge 

As it can be seen , assoc 10 give not the real XYZ .  As by VLA-GET-CENTER

See attached 

It should be  to so do , surface by surface as after such transforms from the catia, entity are not in a  coordinated way . 

Or maybe it can be done in a foreach en from SS-ent-list.

 

As I say , I'm a Peter the flintstone  . or Pedro picapiedra

 

It is may way to work on. 

 

 

 

 

 

 

 

  

linea por var .dwg linea por assoc 10.dwg primer tarmo recto origen 0 0 0.dwg surfaces coloreadas a mano.dwg

Link to comment
Share on other sites

Hi Jack, I had a time to play with this task in the way you are looking for, and I did it... Test this code :

 

(defun c:3dtube-pathlines-table ( / unique s ss cil c ccl ccn ccnl ccnn lil lilpairs p1 p2 p3 p4 ip d a h an r data f fn el )

  (defun unique ( l )
    (if l (cons (car l) (unique (vl-remove-if '(lambda ( x ) (and (equal (car x) (caar l) 1e-6) (or (equal (cadr x) (cadar l) 1e-6) (equal (mapcar '- (cadr x)) (cadar l) 1e-6)))) l))))
  )

  (prompt "\nPick 3DSOLID TUBE...")
  (if (setq s (ssget "_+.:E:S:L" '((0 . "3DSOLID"))))
    (progn
      (vl-cmdf "_.UNDO" "_BE")
      (initcommandversion)
      (vl-cmdf "_.EXPLODE" s)
      (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
      (initcommandversion)
      (vl-cmdf "_.EXPLODE" "_P")
      (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
      (setq ss (ssget "_P" '((0 . "CIRCLE"))))
      (setq cil (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
      (setq c (car (entsel "\nPick starting CIRCLE...")))
      (while (not c)
        (prompt "\nMissed...")
        (setq c (car (entsel "\nPick starting CIRCLE...")))
      )
      (setq ccl (mapcar '(lambda ( p c ) (trans p c 0)) (mapcar '(lambda ( p ) (cdr (assoc 10 (entget p)))) cil) cil))
      (setq ccn (list (trans (cdr (assoc 10 (entget c))) c 0) (cdr (assoc 210 (entget c)))))
      (setq ccnl (unique (mapcar '(lambda ( c ci ) (list c (cdr (assoc 210 (entget ci))))) ccl cil)))
      (while (and (cadr ccnl) (vl-remove-if-not '(lambda ( x ) (or (equal (cadr x) (cadr ccn) 1e-6) (equal (cadr x) (mapcar '- (cadr ccn)) 1e-6))) ccnl))
        (setq ccnl (vl-remove-if '(lambda ( x ) (and (equal (car x) (car ccn) 1e-6) (or (equal (cadr x) (cadr ccn) 1e-6) (equal (cadr x) (mapcar '- (cadr ccn)) 1e-6)))) ccnl))
        (setq ccnn (car (vl-sort (vl-remove-if-not '(lambda ( x ) (or (equal (cadr x) (cadr ccn) 1e-6) (equal (cadr x) (mapcar '- (cadr ccn)) 1e-6))) ccnl) '(lambda ( a b ) (< (distance (car ccn) (car a)) (distance (car ccn) (car b)))))))
        (if ccnn
          (progn
            (setq lil (cons (entmakex (list '(0 . "LINE") (cons 10 (car ccn)) (cons 11 (car ccnn)))) lil))
            (setq ccn (car (vl-sort (vl-remove ccnn ccnl) '(lambda ( a b ) (< (distance (car ccnn) (car a)) (distance (car ccnn) (car b)))))))
          )
        )
      )
      (setq lil (reverse lil))
      (setq lilpairs (mapcar '(lambda ( l1 l2 ) (list l1 l2)) lil (cdr lil)))
      (foreach pair lilpairs
        (setq p1 (cdr (assoc 10 (entget (car pair)))))
        (setq p2 (cdr (assoc 11 (entget (car pair)))))
        (setq p3 (cdr (assoc 10 (entget (cadr pair)))))
        (setq p4 (cdr (assoc 11 (entget (cadr pair)))))
        (setq ip (inters p1 p2 p3 p4 nil))
        (setq d (distance ip p2))
        (setq a (/ (distance p2 p3) 2.0))
        (setq h (sqrt (- (expt d 2) (expt a 2))))
        (setq an (atan a h))
        (setq r (* d (/ (sin an) (cos an))))
        (setq data (cons (strcat (rtos (car p1) 2 20) "," (rtos (cadr p1) 2 20) "," (rtos (caddr p1) 2 20) "," (if (null rl) "0.0" (rtos (car rl) 2 20))) data))
        (setq rl (cons r rl))
        (setq data (cons (strcat (rtos (car p2) 2 20) "," (rtos (cadr p2) 2 20) "," (rtos (caddr p2) 2 20) "," (if (null rl) "0.0" (rtos (car rl) 2 20))) data))
        (if (equal pair (last lilpairs) 1e-6)
          (progn
            (setq data (cons (strcat (rtos (car p3) 2 20) "," (rtos (cadr p3) 2 20) "," (rtos (caddr p3) 2 20) "," (if (null rl) "0.0" (rtos (car rl) 2 20))) data))
            (setq rl nil)
            (setq data (cons (strcat (rtos (car p4) 2 20) "," (rtos (cadr p4) 2 20) "," (rtos (caddr p4) 2 20) "," (if (null rl) "0.0" (rtos (car rl) 2 20))) data))
          )
        )
      )
      (foreach pair lilpairs
        (setq p1 (cdr (assoc 10 (entget (car pair)))))
        (setq p2 (cdr (assoc 11 (entget (car pair)))))
        (setq p3 (cdr (assoc 10 (entget (cadr pair)))))
        (setq p4 (cdr (assoc 11 (entget (cadr pair)))))
        (setq ip (inters p1 p2 p3 p4 nil))
        (entupd (cdr (assoc -1 (entmod (subst (cons 11 ip) (assoc 11 (entget (car pair))) (entget (car pair)))))))
        (entupd (cdr (assoc -1 (entmod (subst (cons 10 ip) (assoc 10 (entget (cadr pair))) (entget (cadr pair)))))))
      )
      (setq data (reverse data))
      (setq f (getfiled "Specify CSV file with TUBE data to save..." "TUBE" "csv" 1))
      (setq fn (open f "w"))
      (foreach x data
        (write-line x fn)
      )
      (close fn)
      (setq ss (ssadd))
      (foreach li lil
        (ssadd li ss)
      )
      (setq el (entlast))
      (initcommandversion)
      (vl-cmdf "_.JOIN" ss)
      (while (< 0 (getvar 'cmdactive)) (vl-cmdf ""))
      (if (not (eq el (entlast)))
        (setq el (entlast))
        (foreach li lil
          (if (and li (not (vlax-erased-p li)))
            (setq el li)
          )
        )
      )
      (vl-cmdf "_.COPYBASE" "_non" '(0.0 0.0 0.0) el "")
      (vl-cmdf "_.UNDO" "_B")
      (vl-cmdf "_.PASTECLIP" "_non" '(0.0 0.0 0.0))
      (startapp "EXPLORER" f)
    )
  )
  (princ)
)

Regards, M.R.

Edited by marko_ribar
Link to comment
Share on other sites

But something's wrong... When I output CSV file from your posted 3DTUBE and get data and then I use that data with Roy's code, I get different 3DTUBE... Is it perhaps the thing that Roy used coordinates of line intersections and not like you showed in your last table XC, YC, ZC - C is circle I suppose... Jack, what exactly do you need : XC, YC, ZC or compatibility between Roy's code and my?

See attachments...

M.R.

test-tubes.dwg TUBE.csv

Link to comment
Share on other sites

I've changed my lisp, should be more reliable now... But still, I can't be 100% sure, if you find some lack, upload DWG for me to see it...

Regards, M.R.

Link to comment
Share on other sites

Wow..you guys have been busy.   sorry...I was out of touch for a few days.  Lots of stuff going on...friends and family both in crisis.  I'm back now and will try to answer everyone's questions.   Thanks for all you've done.  I really appreciate it. 

 To everyone who reads this...I hope you and your families all stay healthy and are not touched by the current pandemic.  I will pray to God that is so.   My own family has avoided it thus far, though I have a dear friend that is had a heart attack a few days ago.  His treatment is being delayed by the covid crisis.   If you are a person of faith, please pray for him.   

 

Thanks for all your hard work.  As I said, i'll go through all the responses and try to answer all the questions you've asked, and provide any info I can.

 

Back soon...

Link to comment
Share on other sites

Haven't forgotten about this...work exploded...been doing 12 hr days.  Everyone else slowing down over the pandemic, but we are getting pounded with more business than we've seen in a while!

 

Everyone stay healthy...and in the words of Gen. MacArthur..."I shall return!"

Link to comment
Share on other sites

  • 1 month later...

Well, it finally slowed down enough for me to get back on this project.

 

I just want to say thanks to everyone who participated!  Your help was invaluable.

 

marko_ribar, your lisp works perfectly, at least on the two parts I've tried it on this morning.   

 

Again, I apologize for the long absence.  The trouble with working for a defense contractor is that when everybody else slows down for something like what we've been experiencing the last few months, our work redoubled!  As  i said before, I've been working 10 and 12 hrs a day, and most weeks have been 6 days!

 

At any rate, we've had a small break in the action (probably hexed it by saying so...lol) so I just wanted to thank everyone properly.  Have a great weekend!

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