Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Crash is gone; Next problem

  1. #1
    Member
    Join Date
    2008-09
    Posts
    9
    Login to Give a bone
    0

    Default Crash is gone; Next problem

    I am looking for a clean method for a program to find how many decimal places a dimension has so I can write it correctly to a txt file. I am using assoc 42 with ssget function to extract the dimension.
    I could turn it into a string an walk through it with a counter, but I am hoping there is a much cleaner method.

    This is the same code I posted yesterday under "Crash using a "while" statement" with corrections.

    Code:
    (defun c:BB ()
    
    (Setvar "osmode" 0)
    (setq INFOLST nil)
    (setq T1 1)
    (setq SS 1)
    
    (while (/= SS nil)
    
        (Prompt "Pick Dimension")
        (setq SS (ssget))
            (if (/= SS nil)
                (progn
                    (setq ELST (entget(ssname SS 0))
                          P1 (cdr(assoc 11 ELST))
                          P2 (list (+ (car P1) 0.55)(+ (cadr P1) 0.38) 0.0)
                          P3 (list (- (car P2) 0.10)(- (cadr P2) 0.10) 0.0)
                    )
                    (command "circle" P2 0.25 "")
        
                    (setq T2 (itoa T1))
                    (command "text" P3 "0.180" "0" T2)
    
                    (setq D1 (cdr(assoc 42 ELST))
                          D1 (rtos D1 2 3)
                          INFOLST (append INFOLST (list D1))
                          T1 (1+ T1)
                    )
    
                );end progn
            );end if
    );end while
    
    ;Write INFOLST out to file
    
     (setq R (length INFOLST)
           FN "c:\\cad\\Iso9000.txt"
           I 0
          TEX (open FN "w")
     )
          (repeat R
              (setq L (nth I INFOLST))
              (write-line L TEX)
              (setq I (1+ I))
          )
    (close TEX)
    
    (princ)
    )
    (princ)
    Last edited by Opie; 2008-09-10 at 01:06 PM. Reason: [CODE] tags added, see Moderator Note

  2. #2
    Member
    Join Date
    2004-08
    Location
    Beautiful OH
    Posts
    29
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    dwbrink,

    Why can't you just use string length?

    Paula

  3. #3
    Member
    Join Date
    2008-09
    Posts
    9
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    Paula

    You are partially there. I can parse the string until I find the decimal point,remove what is left of the point plus the point and than do a string length on what is remaining. What I was hoping for was a single function to avoid the parsing process.
    Thanks anyway!

    David

  4. #4
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    (SETQ rv (ATOF strv));coverts a string to a real
    (SETQ nstrv (RTOS rv 2 0));converts a real to a string reflecting percision

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    Quote Originally Posted by dwbrink View Post
    . . .I could turn it into a string an walk through it with a counter, but I am hoping there is a much cleaner method. . . .
    That is wery tricky because (rtos real 2 n ) will give you different numbers of decimals, even with trailing zeros.

    Try (getvar "DIMDEC" )

    : ) Happy Computing !

    kennet

  6. #6
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    Opps, I guess RTOS rounds the real up(from .5) when applying precision

  7. #7
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    See if this gets you what you want. If not, then it should get you going on the right track.

    Code:
    (defun c:Test (/ Sel EntData BlkEnt Str Pos)
        
        (if
            (and
                (setq Sel (entsel "\n Select dimension: "))
                (= (cdr (assoc 0 (setq EntData (entget (car Sel))))) "DIMENSION")
                (setq BlkEnt (tblobjname "block" (cdr (assoc 2 EntData))))
            )
            (while (setq BlkEnt (entnext BlkEnt))
                (if (= (cdr (assoc 0 (setq EntData (entget BlkEnt)))) "MTEXT")
                    (progn
                        (setq Str (cdr (assoc 1 EntData)))
                        (if (setq Pos (vl-string-search ";" Str))
                            (setq Str (substr Str (+ 2 Pos)))
                        )
                    )
                )
            )
        )
        Str
    )

  8. #8
    Member
    Join Date
    2008-09
    Posts
    9
    Login to Give a bone
    0

    Smile Re: Crash is gone; Next problem

    Tim Willey

    This does get the "dimension" value reflecting (dimdec) and not (luprec) which was my problem using (assoc 42). Thank you for that, but I am not sure what you are doing. It would be greatly appreciated if you could make this code more linear or add some comments.
    Thanks again for the direction.
    David

  9. #9
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    David,

    I think it is pretty simple once you understand how Acad stores the dimension information. The dimension is a block, and all the lines and texts are entities within that and get updated per the dim style, so with that said I'll break it down a little for you.

    The first set of statements ( within the and ):
    Select an entity.
    Check to make sure it is a dimension.
    Get the ename of the block that defines the selected dimension.

    The next step is the while statement with a call to entnext. I use this since a block definition is a collection of entities. So the next entity after we get the block definition block, which is a place holder to say where the block starts, is the first entity that makes up the block. We don't know the order the block is made, but we do know that we shouldn't have more than one mtext entity, so we are just checking each entity to see if it is the mtext entity, which is what is shown in the drawing. Once we know we have a mtext entity, then we just grab the value of it. I noticed that it had a formation code when I tested this on a simple drawing, that is why we check the string value for ';'. If it has that, then return what is after it, as that is what is really shown as the dimension value.

    Hope that makes sense. You're welcome.

  10. #10
    Member
    Join Date
    2008-09
    Posts
    9
    Login to Give a bone
    0

    Default Re: Crash is gone; Next problem

    Tim Willey

    Yes! that makes perfect sence and I learned some things I did not know.
    Thankyou again.

    David

Page 1 of 2 12 LastLast

Similar Threads

  1. Can't Get Journal to fix crash/test crash
    By Hulston1982 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2008-07-07, 08:58 PM
  2. Tag Leader Crash problem fixed in 2009?
    By mzabritski in forum Revit Architecture - General
    Replies: 3
    Last Post: 2008-05-01, 03:23 PM
  3. STC crash!! Help
    By Shaun v Rooyen in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 20
    Last Post: 2005-10-23, 02:55 PM
  4. crash, bang, wallop! ( Radiosity Crash)
    By gmak in forum Revit - Rendering
    Replies: 4
    Last Post: 2004-07-16, 09:20 PM
  5. crash, bang, wallop! ( Radiosity Crash)
    By gmak in forum Revit Architecture - General
    Replies: 2
    Last Post: 2004-07-15, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •