Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Centerline along length of 3d soild shape

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Stuboy
3771 Views, 13 Replies

Centerline along length of 3d soild shape

Has anyone seen a lisp to draw a line along the length of a 3d solid? I have some UB (I sections) columns and beams modeled and would like to select all solids and for it draw a centerline end to end, any hep would be greatly appreciated

 

Stu

13 REPLIES 13
Message 2 of 14
mid-awe
in reply to: Stuboy

None that I've seen, but last I worked with LISP in 3D there was no method for sub-entity selections (which usually require holding the control key while clicking the face/edge/vertex).

 

*check out this old thread which never a solution was found.

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/ssget-edges/td-p/1893730/page/2#M2335...

Message 3 of 14
hmsilva
in reply to: Stuboy

Hi Stu,

 

not the answer that you are waiting, but maybe this thread helps...

Attache a sample dwg, with a few objects.

 

HTH

Henrique

EESignature

Message 4 of 14
Kent1Cooper
in reply to: Stuboy


@Stuboy wrote:

Has anyone seen a lisp to draw a line along the length of a 3d solid? I have some UB (I sections) columns and beams modeled and would like to select all solids and for it draw a centerline end to end, any hep would be greatly appreciated

....


Are they all orthogonally oriented, and with ends cut perpendicular to their lengths?  If, so, I can imagine a way to calculate where the ends are, assuming they're the smallest opposite faces of the bounding boxes, and draw Lines between the middles of those.

Kent Cooper, AIA
Message 5 of 14
Stuboy
in reply to: Kent1Cooper

Hi guys thanks for your help,

 

The ends are cut perpindicular to its length so what you perceive is true kent, Most entities are orthogonal well the columns and beams but there is also some wall bracing as you can imagine, but worst case i can draw the centerlines for those in. there is a centroid.lsp out there that puts a 'point' in at the COG, which could be used maybe using the bounding box at the ends and lenthen a line from that 'point', but your way is probably easier kent, you always seem to have an easier may, haha. would be good to select multiple entities at once though. attached a dwg, I have stripped most of the steel out to reduce size but it will give you an idea of what i am talking about.

 

again thanks all

 

stu 

Message 6 of 14
hmsilva
in reply to: Stuboy

Stu,

did you checked the link at my previous post?

There, I pointed a way to achieve your objective...

 

Maybe this code lead you to the right solution. Smiley Wink

As a "demo", a quick one, minimally tested:

 

(defun c:CtrLine (/ CTRD HND ITM NUM POS POS1 SS TMP TYP VECT VLAOBJ)
  (prompt "\nSelect 3D Solids to draw Centerlines: ")
  (if (setq ss (ssget '((0 . "3DSOLID"))))
    (progn
      (setq itm	0
	    num	(sslength ss)
      );; setq
      (while (< itm num)
	(setq hnd    (ssname ss itm)
	      vlaobj (vlax-ename->vla-object hnd)
	      ctrd   (vlax-get vlaobj 'Centroid)
	      typ    (vlax-get vlaobj 'SolidType)
	);; setq
	(cond ((eq typ "Cylinder")
	       (setq pos  (vlax-get vlaobj 'Position)
		     tmp  (mapcar '- pos ctrd)
		     pos1 (mapcar '- ctrd tmp)
	       );; setq
	       (entmake
		 (list
		   '(0 . "LINE")
		   '(8 . "CtrLine")
		   (cons 10 pos)
		   (cons 11 pos1)
		 )
	       );; entmake
	      )
	      ((eq typ "Extrusion")
	       (setq vect (cdr (assoc 10 (entget (cdr (assoc 360 (member '(100 . "AcDbEvalGraph")
			  (entget (cdr (assoc 360 (member '(100 . "AcDbShHistory")
			  (entget (cdr (assoc 350 (member '(100 . "AcDb3dSolid")
			  (entget hnd)))))))))))))))
		     );; setq
	       (setq tmp  (mapcar '/ vect '(2. 2. 2.))
		     pos  (mapcar '+ ctrd tmp)
		     pos1 (mapcar '- ctrd tmp)
	       )
	       (entmake
		 (list
		   '(0 . "LINE")
		   '(8 . "CtrLine")
		   (cons 10 pos)
		   (cons 11 pos1)
		 )
	       );; entmake
	      )
	);; cond
	(setq itm (1+ itm))
      );; while
    );; progn
  );; if
  (princ)
);; CtrLine

Hope that helps
Henrique

EESignature

Message 7 of 14
Stuboy
in reply to: hmsilva

Your the man henrique, that works a treat I can add additionally what I need to it, thanks again all for your help, greatly appreciated gents..

Stu
Message 8 of 14
hmsilva
in reply to: Stuboy


@Stuboy wrote:
Your the man henrique, that works a treat I can add additionally what I need to it, thanks again all for your help, greatly appreciated gents..

Stu

You're welcome, Stu.

 

But please pay attention that if the 3DSolid is an edited one, with Union, Subtract, Intersect..., the 3DSolid entity don't have a "SolidType" property, and will give an error, this error can be avoided by using something like this, and no ceterline will be created for that edited 3DSolid...

 

(defun c:CtrLine (/ CTRD HND ITM NUM POS POS1 SS TMP TYP VECT VLAOBJ)
  (prompt "\nSelect 3D Solids to draw Centerlines: ")
  (if (setq ss (ssget '((0 . "3DSOLID"))))
    (progn
      (setq itm	0
	    num	(sslength ss)
      );; setq
      (while (< itm num)
	(setq hnd    (ssname ss itm)
	      vlaobj (vlax-ename->vla-object hnd)
	      ctrd   (vlax-get vlaobj 'Centroid));; setq
	(if (vl-catch-all-error-p
		   (vl-catch-all-apply (function (lambda ()
			(vlax-get vlaobj 'SolidType)))))
	  (setq typ "")
	  (setq typ (vlax-get vlaobj 'SolidType))
	  );; if
	(cond ((eq typ "Cylinder")
	       (setq pos  (vlax-get vlaobj 'Position)
		     tmp  (mapcar '- pos ctrd)
		     pos1 (mapcar '- ctrd tmp)
	       );; setq
	       (entmake
		 (list
		   '(0 . "LINE")
		   '(8 . "CtrLine")
		   (cons 10 pos)
		   (cons 11 pos1)
		 )
	       );; entmake
	      )
	      ((eq typ "Extrusion")
	       (setq vect (cdr (assoc 10 (entget (cdr (assoc 360 (member '(100 . "AcDbEvalGraph")
			  (entget (cdr (assoc 360 (member '(100 . "AcDbShHistory")
			  (entget (cdr (assoc 350 (member '(100 . "AcDb3dSolid")
			  (entget hnd)))))))))))))))
		     );; setq
	       (setq tmp  (mapcar '/ vect '(2. 2. 2.))
		     pos  (mapcar '+ ctrd tmp)
		     pos1 (mapcar '- ctrd tmp)
	       )
	       (entmake
		 (list
		   '(0 . "LINE")
		   '(8 . "CtrLine")
		   (cons 10 pos)
		   (cons 11 pos1)
		 )
	       );; entmake
	      )
	);; cond
	(setq itm (1+ itm))
      );; while
    );; progn
  );; if
  (princ)
);; CtrLine

Glad I could help

Henrique

 

EESignature

Message 9 of 14

Hello,  

I tried using this script today 9.5 years later, and it doesnt seems to work with C3d 2020?  

Any tips? 😄   

Thanks 

Message 10 of 14

can this script create multiple vertices polyline along 3d solid pipe if have multiple bends?

Message 11 of 14

@Abhay.KaranjikarQRNDZ 

Can you attached example drawing 

Message 12 of 14

Please find the attached sample 3D Solids received from client

Message 13 of 14

Please find attached Cad file and snap of 3D Solid Pipe

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

Post to forums  

Autodesk Design & Make Report

”Boost