Jump to content

Block counting- need opinions of best technique


Recommended Posts

Posted

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. :oops:

Posted

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))
_$ 

  • 5 months later...
Posted

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.

  • 3 years later...
Posted
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. :oops:

 

Sir,

Please can you post the code.

Posted

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.

Posted

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

Posted
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 :rofl:

Posted
No worries , its just about three years now :rofl:

 

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

Posted
No worries , its just about three years now :rofl:

 

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. :^)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...