Author Topic: XScaleFactor  (Read 2142 times)

0 Members and 1 Guest are viewing this topic.

Humbertogo

  • Guest
XScaleFactor
« on: April 12, 2006, 11:52:10 AM »
I will read the XScaleFactor of a block
i know how the only question is how
to get the scale like i read in the properties
for example
 in vba i get 3.93700787401574E-02

How to convert  3.93700787401574E-02..?

I have a different block units  in the current drawing
« Last Edit: April 12, 2006, 12:05:28 PM by Humbertogo »

RbtDanforth

  • Guest
Re: XScaleFactor
« Reply #1 on: April 12, 2006, 12:50:30 PM »
Assign the answer to a variable. Autocad will do the arithmetic. I wrote theis for working in drawings where folk did things in "pick from air"
Code: [Select]

(DEFUN C:FIX (/ A B C D E F G)(PRINC "CRITS TO FIX")
       (SETQ A (SSGET)
             C (1- (SSLENGTH A ))
        );SETQ
      (WHILE (> C -1)
             (SETQ H (SSNAME A C)
                   D (ENTGET h )
                   C (1- C))
                (FOREACH G (LIST 10 11 13 14 40 41 42 43)
                  (IF (ASSOC G D)(PROGN
                      (SETQ E (CDR(ASSOC G D))
                         F (COND
                           ((LISTP E)(progn
                                      (SETQ E (trans e h 1)
                                            E (subst 0 (last E) E)
                                            E (MAPCAR 'FIXX E)
                                            E (trans e 1 h)
                                            )
                                             ))
                           ((NUMBERP E)(FIXX E))
                           )
                      );SETQ
          (SETQ D (SUBST  (CONS G F) (ASSOC G D) D))
                  )
                  );IF PROGN
               );FOREACH
               (ENTMOD D)
        );WHILE
    'DUN
(TERPRI)
);DEFUN

(DEFUN FIXX (X / S Y Z)
       (SETQ  S (CAR(GETVAR "SNAPUNIT"))
              Q (*  X(/ 1 S))
              Y (FIX Q) Z (+ 1 Y)
              Y1 (- Q Y)Z1 (- Z Q)
              Q  (COND
                  ((= Y1 (MIN Z1 Y1)) Y)
                  ((= Z1 (MIN Z1 Y1))(1+ y))
                  )
              X (* Q S)
       )
)

It uses snapunit to set the rule and Trans allows it to work on skewed lines if the ucs is skewed by the same amount.

Bryco

  • Water Moccasin
  • Posts: 1864
Re: XScaleFactor
« Reply #2 on: April 12, 2006, 06:27:29 PM »
Use a rounding function. Vba does go a little crazy w/ doubles.
And you sometimes don't know if the number is the actual number or just the print out of the number at that time.
Two computers with different processors, graphic cards can give different numbers for the same value.

Code: [Select]
Sub ro()
Debug.Print RoundOff(3.93700787401574E-02, 2)
End Sub

Public Function RoundOff(dblNumber As Double, btPlaces As Byte) As Double
    Dim lngHolder As Long
    lngHolder = 10 ^ btPlaces
    RoundOff = Int((dblNumber * lngHolder) + 0.5) / lngHolder
End Function



EDIT: Wrapped that code in the code wrapper for ya
« Last Edit: April 13, 2006, 07:17:22 AM by nivuahc »

Humbertogo

  • Guest
Re: XScaleFactor
« Reply #3 on: April 13, 2006, 07:56:46 AM »
thanks again
 :-)