Jump to content

dim string, math equation!?


Recommended Posts

Posted

Hey guys, here's a question i HAD is doable.

 

This is for doing concrete slabs at work, which are 1220mm wide.

When we dimension full slabs in a row, our dimension text looks like this

 

example

(4) 8" slabs @ 1220 = 4880

 

the last part is called up automatically depending on width of dimension line you've snapped. So if it is gripped wrong, it might show

 

(4) 8" slabs @ 1220 = 4863 (but the text at beginning still shows 4...)

 

we've been burned on this before, because only the last part updates to the ACTUAL dimension.

 

My question is, is it possible to update the quantity at beginning? this will always show when a dimension is snapped wrong (as it will not give a whole number).

 

I mean like, make the (xxx) number a math equation where it is "TOTAL-DIM-DISTANCE / 1220"

 

THANKS I HOPE THIS MADE SENSE!!!

Posted

So, you want to have an associative formula as dimension's label? I'm afraid that this isn't possible.

The workaround is to use an AutoLISP/VBA routine to insert those dimensions and automatically generate the required format label.

 

Regards,

Posted

How about a bit of FIELD manipulation :twisted:

 

(defun c:Slab ( / doc dim obj )
 ;; © Lee Mac  ~  04.06.10
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

 (initget 6)
 (setq *wid
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Width <"
           (rtos
             (setq *wid
               (cond ( *wid ) ( 1220. ))
             )
           )
           "> : "
         )
       )
     )
     ( *wid )
   )
 )

 (while
   (setq dim
     (SelectifFoo
       (lambda ( x )
         (eq "DIMENSION"
           (cdr (assoc 0 (entget x)))
         )
       )
       "\nSelect Dimension: "
     )
   )
   (vla-put-TextOverride (setq obj (vlax-ename->vla-object dim))
     (strcat "(%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "
       (GetObjectID obj doc) ">%).Measurement>% / " (rtos *wid) " \\f \"%zs8\" >%)"
       " 8\" Slabs @ " (rtos *wid) " = <>"     
     )
   )
   (vla-regen doc AcActiveViewport)
 )
 (princ)
)

(defun GetObjectID ( obj doc )
 ;; © Lee Mac  ~  04.06.10
 (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
   (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
   (itoa (vla-get-Objectid obj))
 )
)

(defun SelectifFoo ( foo str / sel ent )
 ;; © Lee Mac  ~  04.06.10
 (while
   (progn
     (setq sel (entsel str))
     
     (cond
       (
         (vl-consp sel)

         (if (not (foo (setq ent (car sel))))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 ent
)

Posted
How about a bit of FIELD manipulation :twisted:

 

(defun c:Slab ( / doc dim obj )
 ;; © Lee Mac  ~  04.06.10
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

 (initget 6)
 (setq *wid
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Width <"
           (rtos
             (setq *wid
               (cond ( *wid ) ( 1220. ))
             )
           )
           "> : "
         )
       )
     )
     ( *wid )
   )
 )

 (while
   (setq dim
     (SelectifFoo
       (lambda ( x )
         (eq "DIMENSION"
           (cdr (assoc 0 (entget x)))
         )
       )
       "\nSelect Dimension: "
     )
   )
   (vla-put-TextOverride (setq obj (vlax-ename->vla-object dim))
     (strcat "(%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "
       (GetObjectID obj doc) ">%).Measurement>% / " (rtos *wid) " \\f \"%zs8\" >%)"
       " 8\" Slabs @ " (rtos *wid) " = <>"     
     )
   )
   (vla-regen doc AcActiveViewport)
 )
 (princ)
)

(defun GetObjectID ( obj doc )
 ;; © Lee Mac  ~  04.06.10
 (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
   (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
   (itoa (vla-get-Objectid obj))
 )
)

(defun SelectifFoo ( foo str / sel ent )
 ;; © Lee Mac  ~  04.06.10
 (while
   (progn
     (setq sel (entsel str))
     
     (cond
       (
         (vl-consp sel)

         (if (not (foo (setq ent (car sel))))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 ent
)

 

thanks... im not at work so i can't alter this any to try and get it to work, but [i left this out originally] we do 8", 10", 12" -- so im prolly gonna have to tinker so it doesn't call up 8" everytime....

 

[the stuff you have helped me with is unbelievable, Lee]

Posted
so i can't alter this any to try and get it to work

 

Does it not work?

Posted
(defun c:Slab ( / doc dim obj )
 ;; © Lee Mac  ~  04.06.10
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

 (initget 6)
 (setq *dep
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Thickness <"
           (rtos
             (setq *dep
               (cond ( *dep ) ( 8 ))
             )
           )
           "> : "
         )
       )
     )
     ( *dep )
   )
 )

 (initget 6)
 (setq *wid
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Width <"
           (rtos
             (setq *wid
               (cond ( *wid ) ( 1220. ))
             )
           )
           "> : "
         )
       )
     )
     ( *wid )
   )
 )

 (while
   (setq dim
     (SelectifFoo
       (lambda ( x )
         (eq "DIMENSION"
           (cdr (assoc 0 (entget x)))
         )
       )
       "\nSelect Dimension: "
     )
   )
   (vla-put-TextOverride (setq obj (vlax-ename->vla-object dim))
     (strcat "(%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "
       (GetObjectID obj doc) ">%).Measurement>% / " (rtos *wid) " \\f \"%zs8\" >%) "
       (rtos *dep) "\" Slab"
       (if (equal 1.0 (/ (vla-get-Measurement obj) *wid) 1e- "" "s") " @ " (rtos *wid) " = <>"     
     )
   )
   (vla-regen doc AcActiveViewport)
 )
 (princ)
)

(defun GetObjectID ( obj doc )
 ;; © Lee Mac  ~  04.06.10
 (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
   (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
   (itoa (vla-get-Objectid obj))
 )
)

(defun SelectifFoo ( foo str / sel ent )
 ;; © Lee Mac  ~  04.06.10
 (while
   (progn
     (setq sel (entsel str))
     
     (cond
       (
         (vl-consp sel)

         (if (not (foo (setq ent (car sel))))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 ent
)

Posted

thanks, i just tried it and can't seem to even seem to start running it.

 

i added length.lsp to appload autostart, and from looking at your code i should be typing in "slab" to start the lisp

 

as it starts off ...... (defun c:Slab ( doc dim obj )

 

not sure how i'm supposed to be runnign this, because FOR EXAMPLE, it is to be associated within a certain dimstyle (not sure if that matters)

 

example,

 

dimstyle Metric100_HC will have a function in it which automatically enters the distance you have drawn your dim aarows to. From there we just text edit it to say like

 

(8.10.or.12") HC SLABS @ 1220 = xxx (where "xxx" is the length between grips)..

 

How am i to be starting this lisp even :?

Posted

Load the LISP,

 

Type Slab

 

Select an Existing Dimension

Posted
Load the LISP,

 

Type Slab

 

Select an Existing Dimension

 

ya thats why i am confused, because i originally did that, and read that in the code.

 

Does it work on YOUR autocad?

 

the lisp definitely loadded (im looking at it and it said "successful load")

but when i type in slab, it says -- Unknown command "SLAB".

 

even though it shows in the code thats how the lisp should be starting.

Posted
Example:

 

[ATTACH]20649[/ATTACH]

awesome, ya i have NO IDEA what happened, but i just reloadded it and it works now {weird, never changed anything}

 

i know im being picky and btw, VERY grateful for your help, but can all the zero's be suppressed? i tried altering the code but couldnt' get it to work proper.

 

just need it to show 8" 10" 12", and 1220 (without the .xxxx)

 

-----------------------------------

 

ps; where am i editting the quotes to make the " (inch) turn to mm (millimeter) ????

 

i'll need to have one for metric AND imperial jobs,

there's just so many quotes in the code im not sure what is code and what is typed in your output as a quotation

Posted

SI = Slab Imperial

 

SM = Slab Metric

 

(defun c:SI nil (Slab t))

(defun c:SM nil (Slab nil))

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

(defun Slab ( unit / *error* doc dim obj dep wid )
 ;; © Lee Mac  ~  04.06.10
 (vl-load-com)

 (defun *error* ( msg )
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )
 
 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

 (mapcar (function set) '(dep wid)
   (if unit (list *depi *widi) (list *depm *widm)))

 (initget 6)
 (setq dep
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Thickness <"
           (rtos
             (setq dep
               (cond ( dep ) ( (if unit 8 200) ))
             )
           )
           "> : "
         )
       )
     )
     ( dep )
   )
 )

 (initget 6)
 (setq wid
   (cond
     (
       (getdist
         (strcat "\nSpecify Slab Width <"
           (rtos
             (setq wid
               (cond ( wid ) ( (if unit 1220 30500) ))
             )
           )
           "> : "
         )
       )
     )
     ( wid )
   )
 )

 (while
   (setq dim
     (SelectifFoo
       (lambda ( x )
         (eq "DIMENSION"
           (cdr (assoc 0 (entget x)))
         )
       )
       "\nSelect Dimension: "
     )
   )
   (vla-put-TextOverride (setq obj (vlax-ename->vla-object dim))
     (strcat "(%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "
       (GetObjectID obj doc) ">%).Measurement>% / " (rtos wid 2 0) " \\f \"%zs8\" >%) "
       (rtos dep 2 0) (if unit "\"" "mm") " Slab"
       (if (equal 1.0 (/ (vla-get-Measurement obj) wid) 1e- "" "s") " @ " (rtos wid 2 0) " = <>"     
     )
   )
   (vla-regen doc AcActiveViewport)
 )

 (mapcar (function set) (if unit '(*depi *widi) '(*depm *widm)) (list dep wid))
 (princ)
)


(defun GetObjectID ( obj doc )
 ;; © Lee Mac  ~  04.06.10
 (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
   (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
   (itoa (vla-get-Objectid obj))
 )
)

(defun SelectifFoo ( foo str / sel ent )
 ;; © Lee Mac  ~  04.06.10
 (while
   (progn
     (setq sel (entsel str))
     
     (cond
       (
         (vl-consp sel)

         (if (not (foo (setq ent (car sel))))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 ent
)

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