Author Topic: Doing Math inside a DIM line  (Read 2877 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Doing Math inside a DIM line
« on: April 05, 2006, 08:01:07 AM »
Is it possible to have the dim command (either Horz Vert / or Aligned) to pick A and then pick B and place the Dimension on the line, BUT it can take the (VAULE) and divide it by a number and place that in front of the dim.

Finally would like this:

9 SPACES @ 9'-0" = 81.0

3 SPACES @ 9'-0" = 27.0

10 SPACES @ 9'-0" = 90.0


hOPE FULLY that makes sense.
Civil3D 2020

LE

  • Guest
Re: Doing Math inside a DIM line
« Reply #1 on: April 05, 2006, 09:49:01 AM »
Hi;

What do you got so far?... I have seen similar routines that can do what you are asking.... let me check if I had some code about it too.

LE

  • Guest
Re: Doing Math inside a DIM line
« Reply #2 on: April 05, 2006, 10:15:44 AM »
Ok... here is a very simple routine, you can add more stuff into it.

Code: [Select]
(vla-load-com)
(defun C:TST  (/ ename obj dim div total fract)
  (setq ename (car (entsel "\nSelect dimension: ")))
  (setq obj (vlax-ename->vla-object ename))
  (setq dim (vla-get-measurement obj))
  (if (not def)
    (setq def 1))
  (setq div (getdist (strcat "\nDivide into <" (rtos def) ">: ")))
  (if (not div)
    (setq div def)
    (setq def div))

  (setq total (/ dim div))
  (setq fract (- total (fix total))) ;; what are you going to do with this value?

  (vla-put-textoverride
    obj
    (strcat (itoa (fix total))
    " SPACES @ "
    (rtos div)
    " = "
    (rtos (* (fix total) div) 2 1)))
  (princ))

GDF

  • Water Moccasin
  • Posts: 2081
Re: Doing Math inside a DIM line
« Reply #3 on: April 05, 2006, 10:16:11 AM »
Is it possible to have the dim command (either Horz Vert / or Aligned) to pick A and then pick B and place the Dimension on the line, BUT it can take the (VAULE) and divide it by a number and place that in front of the dim.

Finally would like this:

9 SPACES @ 9'-0" = 81.0

3 SPACES @ 9'-0" = 27.0

10 SPACES @ 9'-0" = 90.0

hOPE FULLY that makes sense.


Here is one for dimensioning stairs vertically and horizontally, just modify to suite....<modified the code>


Code: [Select]
;;;vertical
(defun c:STAIRDIMV  (/ PT1 PT2 RISERx RISER# STAIRHT ENT DVAL)
 ;;(ARCH:F_S-VAR)
 ;;(cond ((= ARCH#CLAY "Off") (ARCH:CUSTOM_LAYERS-DIMS)))
 (setvar "osmode" 111)
 (setq PT1 (getpoint "\n* Pick Stairs Start Point *"))
 (setq PT2 (getpoint PT1 "\n* Pick Stairs End Point *"))
 ;;(command ".dimlinear" pt1 pt2 pause)
 
 (command ".dim1" "vertical" PT1 PT2 pause "" ^c^c)
 
 (setq PLACEMENT 1) ;same line 
 (if (= ARCH#SRIS nil)
   (setq ARCH#SRIS 7)) 
 ;;(setq STAIRHT (distance PT1 PT2))
 (setq STAIRHT (- (cadr PT1)(cadr PT2)))
 (if (< STAIRHT 0)(setq STAIRHT (* STAIRHT -1)))
 (setq RISERx (/ STAIRHT ARCH#SRIS))
 (if (> RISERx (fix RISERx))(setq RISERx (+ (fix RISERx) 1)))
 (setq RISER# (rtos RISERx 2 0))
 (setq ARCH#SREQ (strcat " \(" RISER# " EQ RISERS\)"))
 (setq ENT (entlast))
 (setq ENT  (entget ENT)
       DVAL (cdr (assoc 1 ENT)))
 (if (= DVAL "")
   (setq DVAL "<>"))
 (if (= PLACEMENT 1)
   (setq ARCH#SREQ (strcat DVAL " " ARCH#SREQ))
   (progn (if (wcmatch DVAL "*\\X*")
            (setq ARCH#SREQ (strcat DVAL "\\P" ARCH#SREQ))
            (setq ARCH#SREQ (strcat DVAL "\\X" ARCH#SREQ)))))
 (entmod (subst (cons 1 ARCH#SREQ) (assoc 1 ENT) ENT))
 ;;(ARCH:F_R-VAR)
 (princ))

;;;horizontal
(defun c:STAIRDIMH  (/ PT1 PT2 TREADx TREAD# STAIRLN ENT DVAL)
 ;;(ARCH:F_S-VAR)
 ;;(cond ((= ARCH#CLAY "Off") (ARCH:CUSTOM_LAYERS-DIMS)))
 (setvar "osmode" 111) 
 
 (setq PT1 (getpoint "\n* Pick Stair ''Plan'' Start Point *"))
 (setq PT2 (getpoint PT1 "\n* Pick Stair ''Plan'' End Point *"))
 (setq STAIRLN (distance PT1 PT2))
 
 (if (= ARCH#STRD nil)
   (setq ARCH#STRD 11))
 (setq TREADx (/ STAIRLN (- ARCH#STRD 1)))
 (setq TREAD# (rtos TREADx 2 0))
 (setq ARCH#STEQ (strcat " \(" TREAD# " EQ TREADS\)"))
 (cond
   ((= STAIRinx 0)(command ".dim1" "aligned" PT1 PT2 pause "" ^c^c))
   ;;((= STAIRinx 1)(command ".dimlinear" pt1 pt2 pause))
   ((= STAIRinx 1)(command ".dim1" "horizontal" pt1 pt2 pause "" ^c^c))
 )
 (setq PLACEMENT 1) ;same line
 (setq ENT (entlast))
 (setq ENT  (entget ENT)
       DVAL (cdr (assoc 1 ENT)))
 (if (= DVAL "")
   (setq DVAL "<>"))
 (if (= PLACEMENT 1)
   (setq ARCH#STEQ (strcat DVAL " " ARCH#STEQ))
   (progn (if (wcmatch DVAL "*\\X*")
            (setq ARCH#STEQ (strcat DVAL "\\P" ARCH#STEQ))
            (setq ARCH#STEQ (strcat DVAL "\\X" ARCH#STEQ)))))
 (entmod (subst (cons 1 ARCH#STEQ) (assoc 1 ENT) ENT))
 ;;(ARCH:F_R-VAR)
 (princ))

Gary


« Last Edit: April 05, 2006, 10:26:46 AM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

zoltan

  • Guest
Re: Doing Math inside a DIM line
« Reply #4 on: April 05, 2006, 10:22:39 AM »
I just threw this one together.  It can replace the DIMLINEAR command.

See what you think:

Code: [Select]
(Defun C:DimSpaces ( / bLoop pntPick iSpaces dDistance oDim dMeasurement )
 (VL-Load-COM )
 
 (SetQ bLoop T )
 (While bLoop
  (InitGet "Spaces Distance" )
  (If (SetQ pntPick (GetPoint "\nSpecify first extension line origin or [Spaces/Distance] <select object>: "))
   (Cond
    ((= pntPick "Spaces")
     (InitGet 7 )
     (SetQ iSpaces (GetInt "\nEnter Number of Spaces: ") )
     (SetQ dDistance nil )
    )
    ((= pntPick "Distance")
     (InitGet 7 )
     (SetQ dDistance (GetDist "\nEnter Distance: ") )
     (SetQ iSpaces nil )
    )
    ((ListP pntPick)
     (SetQ bLoop nil )
    )
   )
   (SetQ bLoop nil )
  )
 )

 (If (Null pntPick)
  (Command "_DIMLINEAR" "" )
  (Command "_DIMLINEAR" pntPick )
 )

 (While (Not (= (GetVar "CMDACTIVE") 0))
  (Command PAUSE )
 )
 
 (SetQ oDim (VLAX-EName->VLA-Object (EntLast)) )
 (SetQ dMeasurement (VLA-Get-Measurement oDim) )

 (Cond
  (iSpaces
   (VLA-Put-TextOverride oDim (StrCat (ItoA iSpaces)
                                      " SPACES @ "
                                      (RtoS (/ dMeasurement iSpaces) (GetVar "DIMLUNIT") (GetVar "DIMDEC") )
                                      " = "
                                      (RtoS dMeasurement (GetVar "DIMLUNIT") (GetVar "DIMDEC") )
                              )
   )
  )
  (dDistance
   (VLA-Put-TextOverride oDim (StrCat (RtoS (/ dMeasurement dDistance ) 2 (GetVar "LUPREC"))
                                      " SPACES @ "
                                      (RtoS dDistance (GetVar "DIMLUNIT") (GetVar "DIMDEC") )
                                      " = "
                                      (RtoS dMeasurement (GetVar "DIMLUNIT") (GetVar "DIMDEC") )
                              )
   )
  )
 )

 (VLA-Update oDim )
 (Redraw )
 
 (TerPri )
 (Prin1 )
)
« Last Edit: April 05, 2006, 10:29:38 AM by zoltan »