solid section , by its parts layer

solid section , by its parts layer

subasio21
Contributor Contributor
1,198 Views
9 Replies
Message 1 of 10

solid section , by its parts layer

subasio21
Contributor
Contributor

hello 

when gettig a 3d solid section , can the generated region be  the same layer with its part?  is it possible to do this with  a lisp ?

0 Likes
Accepted solutions (2)
1,199 Views
9 Replies
Replies (9)
Message 2 of 10

hak_vz
Advisor
Advisor

Here is a section generated using 3 point method. You didn't specify how to create section so this is for a start.

 

(defun c:ssect ( / e eo lay p1 p2 p3 rego)
	(setq e (car (entsel "\nSelect 3d solid >")))
	(cond 
		((and e)
			(setq eo (vlax-ename->vla-object e))
			(cond 
				((= (vlax-get eo 'ObjectName) "AcDb3dSolid")
					(setq lay (vla-get-layer eo))
					(setq p1 (getpoint "\nFirst point of section plane >"))
					(setq p2 (getpoint "\nSecond point of section plane >"))
					(setq p3 (getpoint "\nThird point of section plane >"))
					(command "_.section" e "" p1 p2 p3)
					(setq rego (setq eo (vlax-ename->vla-object (entlast))))
					(vlax-put rego 'Layer lay)
				)
			)
				
		)
	)
(princ)
)

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 3 of 10

hak_vz
Advisor
Advisor
Accepted solution

For multiple 3d solids at different layers cut by single cutting plane defined with 3 non collinear points

 

(defun c:ssectm ( / adoc ss e i eo lay p1 p2 p3 rego *error*)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ (strcat "\nError: " msg))
		)
		(if adoc (vla-endundomark adoc))
		(setvar 'cmdecho 1)
		(princ)
	)
	(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
	(vla-endundomark adoc)
	(vla-startundomark adoc)
	(setvar 'cmdecho 0)	
	(princ "\nSelect 3d solids to cut >")
	(setq
		ss (ssget '((0 . "3DSOLID")))
		i -1 
		e (entlast)
		p1 (getpoint "\nFirst point of section plane >")
		p2 (getpoint "\nSecond point of section plane >")
		p3 (getpoint "\nThird point of section plane >")
	)
	(cond 
		((and ss p1 p2 p3)
			(while (< (setq i (1+ i)) (sslength ss))
				(setq 
					eo (vlax-ename->vla-object (ssname ss i))
					lay (vla-get-layer eo)
				)
				(command "_.section" (ssname ss i) "" p1 p2 p3)
				(while (setq e (entnext e))
					(setq rego (setq eo (vlax-ename->vla-object e)))
					(vlax-put rego 'Layer lay)
				)
				(setq e (entlast))
		  )		
		)
	)
	(vla-endundomark adoc)
	(setvar 'cmdecho 1)	
	(princ "\nDone!")
	(princ)
)

 

 

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 4 of 10

subasio21
Contributor
Contributor

thanks a lot  this is great. 
also can you add the height of parts?

0 Likes
Message 5 of 10

hak_vz
Advisor
Advisor

@subasio21 wrote:

thanks a lot  this is great.  also can you add the height of parts?


Height of part? Can you  explain in more details?

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 6 of 10

subasio21
Contributor
Contributor

hello , thanks again 

 

3d solid parts has the hight ( thickness )  

 

subasio21_0-1620039461477.png

 

0 Likes
Message 7 of 10

hak_vz
Advisor
Advisor

@


@subasio21 wrote:

hello , thanks again 

 

3d solid parts has the height ( thickness )  


I know, but how do I have to show it. Are you thinking about some kind of auto dimensioning?

I'll guess your section plane is always vertical.

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 8 of 10

subasio21
Contributor
Contributor

hello 

 

it can be change the color of reigon,  I mean when the parts thicknees is 20 than generated region color can be 20. so I will know what is the thickness of part

 

subasio21_0-1620217735655.png

 

 

 

 

0 Likes
Message 9 of 10

hak_vz
Advisor
Advisor
Accepted solution
(defun c:ssectm ( / adoc ss e i eo lay p1 p2 p3 rego height *error*)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ (strcat "\nError: " msg))
		)
		(if adoc (vla-endundomark adoc))
		(setvar 'cmdecho 1)
		(princ)
	)
	(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
	(vla-endundomark adoc)
	(vla-startundomark adoc)
	(setvar 'cmdecho 0)	
	(princ "\nSelect 3d solids to cut >")
	(setq
		ss (ssget '((0 . "3DSOLID")))
		i -1 
		e (entlast)
		p1 (getpoint "\nFirst point of section plane >")
		p2 (getpoint "\nSecond point of section plane >")
		p3 (getpoint "\nThird point of section plane >")
	)
	(cond 
		((and ss p1 p2 p3)
			(while (< (setq i (1+ i)) (sslength ss))
				(setq 
					eo (vlax-ename->vla-object (ssname ss i))
					lay (vla-get-layer eo)
					height (atoi (rtos(abs(* 2 (caddr (vlax-get eo 'Centroid)))) 2 0))
				)
				(command "_.section" (ssname ss i) "" p1 p2 p3)
				(while (setq e (entnext e))
					(setq rego (setq eo (vlax-ename->vla-object e)))
					(vlax-put rego 'Layer lay)
					(cond ((and (>= height 1)(<= height 255))(vlax-put rego 'Color height)))
				)
				(setq e (entlast))
		  )		
		)
	)
	(vla-endundomark adoc)
	(setvar 'cmdecho 1)	
	(princ "\nDone!")
	(princ)
)

 

This will work only if extruded part height (thickness)  is an integer value in range 1 to 255

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 10 of 10

subasio21
Contributor
Contributor

thanks alot 

best regards 

0 Likes