CADapult Posted February 10, 2011 Posted February 10, 2011 I'd created a lisp routine a while back to insert pipe fitting blocks into a drawing. Blocks are named with a code that indicates connection type, size, and fitting type (elbow, tee, reducer, etc.) only. Now I need to set up the lisp to be able to add material, coating, and pipe schedule information to the blocks as they're inserted so we can extract bills of material. Currently each block is used for every possible material, pipe schedule, etc. the fitting might come in. To make an individual block for each variation needed would multiply the quantity of blocks stored in our system by at least 10x. So, I need some opinions; Do I add the additional data to the blocks as they're inserted by filling in an attribute, or by renaming the block on the fly as it's inserted? I've got several lisp routines that can extract block quantities, but would extracting block quantities based on the attribute text be easier? Warning: I'm a lisp hack at best, so I may be asking for help on this one. Quote
Smirnoff Posted February 10, 2011 Posted February 10, 2011 You can use XData to store your data inside blocks or entities. Here is some functions: (defun Add_XData( Ent ; - Entity Ename App ; - Application name dList ; - XData list (list(cons group data)...) ) (regapp App) (entmod(append(entget Ent)(list(list -3(append(list App)dList))))) ); end of Add_XData ; -------------------------------------------------------------------------------------------------------------------------- (defun Delete_XData( Ent ; - Entity Ename apLst ; - List of Applications / xEnt) (setq xEnt(entget Ent apLst) xEnt(vl-remove(assoc -3 xEnt)xEnt) ); end setq (entmod xEnt) ); end of Delete_XData ; -------------------------------------------------------------------------------------------------------------------------- (defun Read_XData( Ent ; - Entity Ename apName ; - Application name / xEnt) (setq xEnt(entget Ent(list apName)) xEnt(vl-remove apName(cadar (vl-remove-if (function (lambda(a)(/= -3(car a))))xEnt))) ); end setq ); end of Read_XData ; -------------------------------------------------------------------------------------------------------------------------- Visual LISP console example: [color="#0000ff"]; get some entity on screen[/color] _$ (setq ent(car(entsel))) <Entity name: 7ef02390> [color="#0000ff"]; add XData for application 'My Magic App' to entity[/color] _$ (Add_XData ent "My Magic App" (list(cons 1000 "Magic Data 1")(cons 1000 "Magic Data 2"))) ((-1 . <Entity name: 7ef02390>) (0 . "LINE") (330 . <Entity name: 7ef01cf8>) (5 . "1B2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (370 . 70) (100 . "AcDbLine") (10 2183.93 319.511 0.0) (11 2637.11 1054.87 0.0) (210 0.0 0.0 1.0) (-3 ("My Magic App" (1000 . "Magic Data 1") (1000 . "Magic Data 2")))) [color="#0000ff"]; read XData foe the same application[/color] _$ (Read_XData ent "My Magic App") ((1000 . "Magic Data 1") (1000 . "Magic Data 2")) [color="#0000ff"]; delete XData for the same application[/color] _$ (Delete_XData ent (list "My Magic App")) ((-1 . <Entity name: 7ef02390>) (0 . "LINE") (330 . <Entity name: 7ef01cf8>) (5 . "1B2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (370 . 70) (100 . "AcDbLine") (10 2183.93 319.511 0.0) (11 2637.11 1054.87 0.0) (210 0.0 0.0 1.0)) _$ Quote
Vineet Babbar Posted July 12, 2011 Posted July 12, 2011 Hi Cadapult, I need this Block counting lisp from you, if you can provide it to me. Actually, i work on irrigation projects in which i need to make the bill of quantities for all the PVC fittings to be used in the project. Basically, all the pipes in our projects are on different layers and as already told you that we need to take off the fittings. If your lisp works in this scenario, i would request you to please send it to my email address: vineetbabbar@gmail.com Thanks and Regards, Vineet Babbar. Quote
ReMark Posted July 12, 2011 Posted July 12, 2011 Vineet: Check out CADTutor forum member Lee Mac's Block Counter program. http://lee-mac.com/blockcounter.html Quote
anupmadhu Posted December 6, 2014 Posted December 6, 2014 I'd created a lisp routine a while back to insert pipe fitting blocks into a drawing. Blocks are named with a code that indicates connection type, size, and fitting type (elbow, tee, reducer, etc.) only. Now I need to set up the lisp to be able to add material, coating, and pipe schedule information to the blocks as they're inserted so we can extract bills of material. Currently each block is used for every possible material, pipe schedule, etc. the fitting might come in. To make an individual block for each variation needed would multiply the quantity of blocks stored in our system by at least 10x.So, I need some opinions; Do I add the additional data to the blocks as they're inserted by filling in an attribute, or by renaming the block on the fly as it's inserted? I've got several lisp routines that can extract block quantities, but would extracting block quantities based on the attribute text be easier? Warning: I'm a lisp hack at best, so I may be asking for help on this one. Sir, Please can you post the code. Quote
BIGAL Posted December 7, 2014 Posted December 7, 2014 Maybe look at invisible attributes so you can have lots of data but visually only see a few. As you already have a lisp probably easier to add to your lisp maybe a more generic version that can handle various number of attributes so use only one routine rather than one per block type. Quote
CADapult Posted December 8, 2014 Author Posted December 8, 2014 Sorry this reply has taken a while. I hadn't come back to the thread until today. I do not take any credit for the attached routine, which I found on this site a long while ago. It goes a bit past my programming abilities. I wish I could remember who the author was so they could get credit for it, because it's pretty slick. Run the routine in a drawing and it creates an Excel spreadsheet in the same folder as the drawing. I never did work out a solution for the on-the-fly block renaming. With our switching to Inventor in the near future it isn't critical, but I would have liked to have worked it out. BC.lsp Quote
Tharwat Posted December 8, 2014 Posted December 8, 2014 Sorry this reply has taken a while. I hadn't come back to the thread until today. No worries , its just about three years now Quote
stevesfr Posted December 9, 2014 Posted December 9, 2014 No worries , its just about three years now This BC.lsp could be more valuable if someone could add the name of the drawing somewhere in the beginning of the spreadsheet and also add it to the save Excel fine name. Really prevents confusion when working on a multiple sheet set of plans. thanks for possible additions Steve Quote
CADapult Posted December 10, 2014 Author Posted December 10, 2014 No worries , its just about three years now Hey now, the last request for the block counting LISP was only a few days ago. I'll try to respond within 6 months from now on. Promise. :^) Quote
Recommended Posts
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.