pedit and concrete volume

pedit and concrete volume

k005
Advisor Advisor
1,036 Views
14 Replies
Message 1 of 15

pedit and concrete volume

k005
Advisor
Advisor

 

 

Hello friends;

 

How can I select line-arc or lwpolyline objects, make a "pedit", enter the mold height and print the result as a text

 

object on the drawing?

0 Likes
Accepted solutions (1)
1,037 Views
14 Replies
Replies (14)
Message 2 of 15

hak_vz
Advisor
Advisor

Try this code. I use boundary instead of pedit.

 

(defun c:cvol (/ *error* pt h a th)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
		(setvar 'cmdecho 1)
		(princ)
	)
	(setvar 'cmdecho 0)
	(setq th (getreal "\nText height >"))
	(while (setq pt(getpoint "\nPick a point inside bounding elements >"))
		(command "_.bpoly" pt "")
		(setq
			h (getreal "\nMold height >")
			pt (getpoint "\nText insertion point >")
			a (rtos(* h (vlax-get(vlax-ename->vla-object (entlast)) 'Area))2 2)
		)
		(entdel (entlast))
		(entmake
		  (list
			(cons 0 "TEXT")
			(cons 10 pt)
			(cons 40 th)
			(cons 1 a)
		  )
		)
	)
	(setvar 'cmdecho 1)
	(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.
Message 3 of 15

k005
Advisor
Advisor

@hak_vz 

 

 

it was very good.

 

How can we change the selection to window?
Also, it would be much better if it was taken from the Text height: textsize variable.

Thank you.

0 Likes
Message 4 of 15

hak_vz
Advisor
Advisor

Here is updated version

Point of text insertion is the one you pick inside bounding elements.

Text height is replaced with textsize variable.

 

I would stay with creation of temporary boundary element. There is option with pedit but it don't assure to collect and join all selected entities. Command join is also an option (better) but it modifies first entity in a set and don't create new entity. This seams to me is the fastest version.

Final area text string can be modified using autolisp strcat function with variable a that holds area string.

 

(defun c:cvol (/ *error* pt h a th)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
		(setvar 'cmdecho 1)
		(princ)
	)
	(setvar 'cmdecho 0)
	(setq th (getvar 'textsize))
	(while (setq pt(getpoint "\nPick a point inside bounding elements >"))
		(command "_.bpoly" pt "")
		(setq
			h (getreal "\nMold height >")
			a (rtos(* h (vlax-get(vlax-ename->vla-object (entlast)) 'Area))2 2)
		)
		(entdel (entlast))
		(entmake
		  (list
			(cons 0 "TEXT")
			(cons 10 pt)
			(cons 40 th)
			(cons 1 a)
		  )
		)
	)
	(setvar 'cmdecho 1)
	(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.
Message 5 of 15

k005
Advisor
Advisor

 

@hak_vz 

If we can change the code in this section to : Window. It'll be super.

The reason: to select small size objects without borders. this way it's fast. But it also calculates the Outer frame... whereas only the Inner Frame is required.

 

(setq pn1 (getpoint "\nÜst köşe?"))
(setq pn2 (getcorner pn1 "\nAlt köşe?"))
;(setq pt (ssget "W" pn1 pn2))
(while (setq pt (ssget "W" pn1 pn2))

 

(while (setq pt(getpoint

 

0 Likes
Message 6 of 15

hak_vz
Advisor
Advisor

Attach sample drawing.

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

k005
Advisor
Advisor

@hak_vz 

 

sorry. While I was writing in the other thread, I couldn't notice it..

I added the drawing.

 

 

0 Likes
Message 8 of 15

hak_vz
Advisor
Advisor

Ok. In your sample you have a lot of rectangles representing colons.

 

Explain how you want volume to be calculated.

 

Do you have some outer boundary and volume is area of this boundary minus area of internal entities times mold height?

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 9 of 15

k005
Advisor
Advisor

@hak_vz 

 

Yes. there is no limit. but if we're going to treat it as a border, it's the area of the inner objects times the die height.

0 Likes
Message 10 of 15

hak_vz
Advisor
Advisor
Accepted solution

@k005 wrote:

 

..... it's the area of the inner objects times the die height.


 

This is something completely different.

 

(defun c:cvol (/ *error* pt e h a  ss)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
		(setvar 'cmdecho 1)
		(princ)
	)
	(setq e (entlast))
	(princ "\nSelect entities >")
	(setq ss (ssget '((0 . "*LINE,ARC"))))
	(setvar 'cmdecho 0)
	(command "_pedit" "m" ss "" "y" "j" "" "")
	(setq ss (ssadd))
	(while (setq e (entnext e))(setq ss (ssadd e ss)))
	(setq i -1 a 0)
	(while (< (setq i  (1+ i))(sslength ss))
	(setq e (vlax-ename->vla-object (ssname ss i)))
	(if (vlax-property-available-p e 'Area)(setq a (+ a (vlax-get e 'Area))))
	)
	(setq h (getreal "\nMold height >"))
	(setq pt (getpoint "\nText insertion point"))
	(entmake
	  (list
		(cons 0 "TEXT")
		(cons 10 pt)
		(cons 40 (getvar 'textsize))
		(cons 1 (rtos (* h a) 2 2))
	  )
	)
	(princ (strcat "\n Volume = " (rtos (* h a) 2 2)))
	(setvar 'cmdecho 1)
	(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.
Message 11 of 15

k005
Advisor
Advisor

@hak_vz 

 

Thank you very much. that's exactly what it is.

 

🤗

0 Likes
Message 12 of 15

Sea-Haven
Mentor
Mentor

An alternative method, make a dummy layer, draw a random pline around the objects, do bploy, all shapes will be made into plines, erase outside dummy layer. Note I dont think gcen is supported in Bricscad.

 

; label random pline areas 
; By AlanH July 2021

(defun c:plarea ( / pl oldlay pt ent1 obj ss x a h)

(defun pl ()
	(setq pt (getpoint "\nStarting point  use \"C\" to exit : "))
	(command-s "_.pline" pt)
	(princ)
)

(setq oldlay (getvar 'clayer))
(command "-layer" "M" "dummy" "C" 4 "dummy" "")

(setq h (getreal "\nMould height >"))

(pl)
(setq entl (entlast))

(setq pt (getpoint "\nPick point inside"))
(command "Bpoly" pt "")
(command "erase" ent1 "")
(setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(setq ss (ssget "WP" lst '((8 . "dummy"))))


(repeat (setq x (sslength ss) )
	(setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
	(setq pt (osnap (vlax-curve-getStartPoint obj) "gcen"))
	(setq a (vla-get-area obj))

	(entmake
	  (list
		(cons 0 "TEXT")
		(cons 10 pt)
		(cons 8 oldlay)
		(cons 40 (getvar 'textsize))
		(cons 1 (rtos (* h a) 2 2))
	  )
	)
	(princ (strcat "\n Volume = " (rtos (* h a) 2 2)))
)

(setvar 'clayer oldlay)
(command "-laydel" "N" "dummy" "" "Y")

(princ)
)

(c:plarea)

 

Message 13 of 15

Sea-Haven
Mentor
Mentor

Gcen is supported in Bricscad V20 just double checked, my previous attempt must have had incorrect syntax, thanks Kent for one that works.

 

Instructions.

 

Message 14 of 15

k005
Advisor
Advisor

@Sea-Haven 

 

 

Yes, this is a very good alternative work.

* Can we just add a little: keep it that way. Get a total only at the point we click first or to another point.

0 Likes
Message 15 of 15

Sea-Haven
Mentor
Mentor

If you want just a total answer look at Hak_vz code and change mine where it does the get area and just write the answer as 1 text as in the Hak_vz code. A good place to start to learn about lisp.