H-BEAM WEIGHT LISP .. PLEASE

H-BEAM WEIGHT LISP .. PLEASE

hodlegap09da
Observer Observer
328 Views
4 Replies
Message 1 of 5

H-BEAM WEIGHT LISP .. PLEASE

hodlegap09da
Observer
Observer

I want to make a LISP that picks only objects in the BOM to get weight. Please help

0 Likes
329 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

Give us something to start with.  What is the User expected to do [I see no prompts]?  What about it does not work [I assume there must be something]?  In what way does it not work?  How far does it get?  Etc., etc.

Kent Cooper, AIA
0 Likes
Message 3 of 5

ec-cad
Collaborator
Collaborator

For final results, your image (that looks like a Table), should probably (be) a Table.

I found a few items in the code that you should look at.

I'm assuming that the code you uploaded as 'HW.lsp' is just a portion
of a much larger Lisp.

I see a couple of issues with what you have posted.
(defun ck-num-g (a / n snum sstr sappend m-snum snum-t-nil) <----  is a function,
but I don't see it 'called' from within the C:Hw function.

And, here, there seems to be a typo..
(setq ssn (sslengt des))
Should be:
(setq ssn (sslength des)); note missing h

And here:
(setq des (ssget))
Would allow for picking just about any entity.
And would allow Multiple items to be picked via Window or Crossing or 1 at a time.

Better to prompt for something:

(princ "\nPick a Beam Number:")
(setq des (ssget "_+.:E:S" '((0 . "TEXT")))); to only get 1 item
(if des
(progn
(setq ent (ssname des 0))
(setq elist (entget ent))
(setq BeamNumber (cdr (assoc 1 elist)))
); progn
); if

 

ECCAD

 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

Here's an issue I notice:

 

(if (= (substr tk 1 1) "" )
  (progn
    (setq tk1
      (cond
        ((= tk "100x50x5x7" ) 9.3) ((= tk "100x100x6x8" ) 17.2) .....

 

The (if) test expression means "if the text content of the object [is this about Dimension text override?] is empty."  [It's actually asking whether the first character is nothing, that is, if there is no first character.]  It could be simplified to just this:

(if (= tk "")

Only if that's empty does it go on to try to set tk1 to a value, but all possible values depend on the text content not being empty, so none of the conditions will ever be satisfied, and tk1 will always be nil.

 

Should it be testing for whether the text content is not empty?

(if (/= tk "")

Kent Cooper, AIA
Message 5 of 5

Sea-Haven
Mentor
Mentor

Post a proper dwg with beams in it, your code looks at text but there is no pick object for length so how can you work out "Total weight"

SeaHaven_0-1724804075814.png

Same can sort the beam lengths into say 5m 6 off. 18kg 90kg.

 

I think a true dwg will reveal a lot more, as suggested make a table not text and lines.

0 Likes