Width,depth,length in a table

Width,depth,length in a table

Anonymous
Not applicable
1,473 Views
5 Replies
Message 1 of 6

Width,depth,length in a table

Anonymous
Not applicable

Hello 

Hope you are all doing well ,I am a mechanical engineer working as air conditioning system design engineer . I was wondering if anyone can help me in developing a lisp since my kn owledge about lisp programming is extremely at a low level . My plan is to have a lisp that create a table for duct information .. which are as follows

Width , depth , length 

 

Let us say it will work as follow :

Command : DWT(since this Table will help in calculating duct weight)

Autocad : please enter width value 

Here the user will enter width of the duct and press enter

Autocad : please enter depth value 

Here the user will enter the depth of the duct and hit enter

Autocad : please select legth of duct 

Here the user will select the line that represents the length of duct and press enter

And auto cad will repeat the cycle till the user select close(C)  then cad will reply 

Autocad : please specify the  point for the table 

Then it will place a table with width and depth and length 

I hope you got my point ..can this idea be implemented ? Appreciate anyone who can help 

Kind regards

 

here is a link for dwg sample of what I mean 

https://drive.google.com/file/d/1Wa0jOtYifxck-KOy2ds99BHF8L1v5AeI/view?usp=sharing 

0 Likes
Accepted solutions (1)
1,474 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

My suggestion is work in a 2 1/2 3D mode so a duct would be a rectang, so can get length and width, but use thickness for height can then just select say all rectangs on a layer and table can be made from the 3 properties.

 

SeaHaven_0-1639712434577.png

 

Draw rectang, Then Thickness, then -Vpoint 1,1,1

 

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thank you for your immediate reply 

Regarding your point of view it will help a lot and will save a lot of time and effort .. but since most of our work are shop drawings our layouts are in 2D with text lables on it so I think converting ut to 3D will take more time.

Please forgive my low knowledge but isn't my idea could be implemented ? .. I dont know how lisp work so I cant answer to this question so please let me know 😄

0 Likes
Message 4 of 6

calderg1000
Mentor
Mentor
Accepted solution

Regards @Anonymous 

I found this code and adapted it to your requirements

;;;For bigal 2-08-2015
;; Tharwat 26. 08. 2015 ;
;; mods by BIGAL 29.08.2015 now as table
;;;Edit for Calderg1000, 18-12-21.
;;;-----------------------------------------------------------------------------------------------------------
(defun c:DWT(/ doc curspace pt1 s nline numrows numcolumns rowheigth colwidth objtable x y r pntlist pins itm)
(vl-load-com)
(setq curspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setvar "dynmode" 1)
(setq pt1 (vlax-3d-point (getpoint "\nEnter a point for TABLE Top Left Corner: "))) 
(setq nline(getint "\nIEnter the number of conduits:"))
(setq numrows (+ 2 nline)
	numcolumns 4
	rowheight 7
	colwidth 25)
(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "Table for Duct Information")
(vla-setcolumnwidth objtable 0 15)
(vla-setcolumnwidth objtable 1 25)
(vla-setcolumnwidth objtable 2 30)
(vla-settext objtable 1 0 "Item")
(vla-settext objtable 1 1 "Width")
(vla-settext objtable 1 2 "Depth")
(vla-settext objtable 1 3 "Length")
(vla-SetTextHeight Objtable (+ acDataRow acHeaderRow acTitleRow) 2.0)
(vla-SetAlignment Objtable acDataRow acMiddleCenter)
(setq x 1)
(setq y 2)
(setq r 0)
(repeat nline
  (setq wd (getreal "\nPlease Enter Width Value:")
  	dp (getreal "\nPlease Enter Depth Value:")
	s(entsel "\nPlease Select length of Duct:"))
(setq e (vlax-ename->vla-object(car s))
	itm(vla-settext objtable y 0 (rtos x 2 0)))
(vla-settext objtable y 1 (rtos wd 2 2))
(vla-settext objtable y 2 (rtos dp 2 2))
(vla-settext objtable y 3 (rtos (vla-get-length e) 2 2))
(setq pins (vlax-curve-getpointatparam e (* (+ (vlax-curve-getstartparam e) (vlax-curve-getendparam e))0.5)))
(vl-cmdf "text" "j" "mc" pins 1 0 (strcat "Duct " (itoa (1+ r))))  
(setq x (1+ x ))
(setq y (1+ y ))
(setq r (1+ r ))
);Repeat
(princ)
); defun

 


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

Anonymous
Not applicable

Dear @calderg1000 

I can't say more than Thank you !

You really made it the exact way I want and it works like a charm 

Thank you so much for your time and help 

Message 6 of 6

Sea-Haven
Mentor
Mentor

I would still look into storing extra info if you want just a Line only using xdata its not that hard you would store the width and height attached to the line. Much easier as just select say a layer of lines no need to keep entering width etc.

 

Afralisp xdata is a real good tutorial about using xdata very well explained. It is what you want 1st tutorial is about a LINE.

Extended Entity Data - Part 1 | AfraLISP

 

So you would have 2 lisps set height & width and draw duct. A 3rd would be make table.

 

If you get stuck post again.

 

0 Likes