+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 29
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default change the width of a rectangle need help

    Registered forum members do not see this ad.

    Hello, Can't seem to change the width og my retangle and this is what i tried.

    Code:
    (setq ent(entlast))
    (setq sel(ssget ent))
    
    (setq ent (entget ent))
    (setq oldlist (assoc 43 ent))
    (setq conlist (cons(car ancliste) 18.0))
    (setq newlist (subst conlist oldlist ent))
    (entmod ent)
    and it gives me the error : ; error: bad DXF group: nil

    what am I doing wrong ?

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    The variable ancliste is not defined in your code, resulting in the DXF group (nil . 18.0) hence causing the error: bad DXF group nil.

    In addition, there is no need for the ssget expression, and you are also using entmod with the old DXF data list bound to the ent variable, and not the modified DXF data.

    Consider the following code:
    Code:
    (setq ent (entget (entlast)))
          ent (subst '(43 . 18.0) (assoc 43 ent) ent)
    )
    (entmod ent)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

    Thanks Lee,

    It works, now i'm trying to make it work a diferent way and it won't

    Lets says I change 18.0 to

    Code:
    (setq val 18.0)
    (setq ent (entget (entlast)))       ent (subst '(43 . val) (assoc 43 ent) ent) ) (entmod ent)
    it returns this : ; error: bad DXF group: (43 . VAL)

    Seems to me I can't

    But I figured out what to do while wrtting this message

    Code:
    (setq val 18)
    
    (setq ent (entget (entlast))
          ent (subst (cons (car(assoc 43 ent)) val) (assoc 43 ent) ent)
    )
    Thanks again anyways Your great wisdoms is always in the right spot

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Quote Originally Posted by CadFrank View Post
    Lets says I change 18.0 to
    Code:
    (setq val 18.0)
    (setq ent (entget (entlast)))       ent (subst '(43 . val) (assoc 43 ent) ent) ) (entmod ent)
    it returns this : ; error: bad DXF group: (43 . VAL)

    Seems to me I can't
    The reason that your modification fails is because an expression preceded by an apostrophe is not evaluated, but rather taken as a 'literal' expression (i.e. taken at 'face-value'). Hence, the variable val is not evaluated, but interpreted simply as a symbol (VAL)

    Quote Originally Posted by CadFrank View Post
    Code:
    (setq val 18)
    
    (setq ent (entget (entlast))
          ent (subst (cons (car(assoc 43 ent)) val) (assoc 43 ent) ent)
    )
    Please note:

    Code:
    (car (assoc 43 ent)) = 43
    Hence the code could become:

    Code:
    (setq val 18.0
          ent (entget (entlast))
          ent (subst (cons 43 val) (assoc 43 ent) ent)
    )
    (entmod ent)
    Quote Originally Posted by CadFrank View Post
    Thanks again anyways Your great wisdoms is always in the right spot
    You're very welcome, and thank you for your kind compliments.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  5. #5
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

    Well I have a new question !

    Code:
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                   CE PROGRAM EST CONÇU POUR COFFRER                     ¦¦¦;
    ;¦¦¦                          UNE DALLE DE BÉTON                             ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                   AUTEUR : CadFrank, Copyright ® 2012                   ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                   Ce sous-program défini les calques                    ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    (defun NouveauCalque(/ lay)
    
      (foreach lay '("-LU SYMBOLE")
         (if (not (tblsearch "LAYER" lay))
             
           (progn
             (command "_layer" "_n" "-LU SYMBOLE" "_C" "90" "-LU SYMBOLE" "" "")  
           )
          
         );if
    
      );foreach
    
    ); fin NouveauCalque
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                        Ce sous-program défini les                       ¦¦¦;
    ;¦¦¦                            parametres initial                           ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    (defun Parametreinitial ()
    
      (setq retour (list
                     (cons "osmode" (getvar 'osmode))
                     (cons "clayer" (getvar 'clayer))
                   )
      )
      (setvar 'OSMODE 0)
        
      retour ; la dernière expression est retournée par la fonction
    
    ); fin parametreinitial
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                        Ce sous-program remet les                        ¦¦¦;
    ;¦¦¦                            parametres initial                           ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    (defun Parametrefin (retour)
    
      (foreach p retour
        (setvar (car p) (cdr p))
      )
    
    );fin parametrefin
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                        Ce sous-program divide                           ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    (defun div (x y / *error*) 
    
      
      (defun *error* (msg)
        (princ (strcat "\nErreur dans la fonction div: " msg))
        (princ)
      )
    
      (/ x (float y))
    )
    
    ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦;
    ;¦¦¦                           PROGRAM PRINCIPAL                             ¦¦¦;
    ;¦¦¦ _______________________________________________________________________ ¦¦¦;
    
    (defun c:BCA (/ Entt pt1 pt2 dist1 dist2 ech1 rec1 rec2)
    
      (NouveauCalque)
      
      (setq init (Parametreinitial))
      
      (initget 1)
      (setq Entt (Entget(car(Entsel))))
    
      (setq pt1 (cdr (assoc '10 Entt)))
      
      (setq dist1 (cdr (assoc '42 Entt)))
    
      
      (setq dist2 (cdr (assoc '43 Entt)))
    
      (setq ech1 (* (float(cdr (assoc '40 Entt))) (div 2 3)))
      (setq ech2 (div (float(cdr (assoc '40 Entt))) 2))
      
      (setq pt2 (list (+ (car pt1) dist1) (- (cadr pt1) dist2)))
    
      (setvar "clayer" "-LU SYMBOLE")
      
      (command "_rectangle" pt1 pt2)
      
      (setq rec1 (entlast))
      
      (command "_offset" ech1 rec1 (polar pt1 180 1) "")
      (command "_erase" rec1 "")
      (setq rec2 (entlast))
      
      (command "_offset" ech1 rec2 (reverse (polar pt1 180 1)) "")
      (setq rec3 (entlast))
      
      (setq rec2 (entget rec2)
            rec2 (subst  (cons 43 ech2) (assoc 43 rec2) rec2)
      )
      (entmod rec2)
      
      (setq rec3 (entget rec3)
            rec3 (subst '(62 . 61) (assoc 62 rec3) rec3)
      )
      (entmod rec3)
      
      (parametrefin init)
      
      (princ)
    )
    now I'm trying to change the color of my rec3 but i've noticed I don't see the dxf code 62 in the entity so I can't really change it. Do I have to use chprop or I can use subst?

  6. #6
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    If the object 's color is ByLayer , the DXF code 62 would be nil , so consider this way which is better than the use of command call .

    e.g.
    Code:
    (setq e (car (entsel)))
    (entmod (append (entget e) '((62 . 1))))
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  7. #7
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

    Quote Originally Posted by Tharwat View Post
    If the object 's color is ByLayer , the DXF code 62 would be nil , so consider this way which is better than the use of command call .

    e.g.
    Code:
    (setq e (car (entsel)))
    (entmod (append (entget e) '((62 . 1))))
    Thank alot! works like a charm.

    But now I Have a new question

    I want to get all the 2d points of my rectangle (rec3)

    Code:
    Select object: ((-1 . <Entity name: 7fffed72200>) (0 . "LWPOLYLINE") (330 . 
    <Entity name: 7fffed379f0>) (5 . "288") (100 . "AcDbEntity") (67 . 0) (410 . 
    "Model") (8 . "-LU SYMBOLE") (62 . 61) (100 . "AcDbPolyline") (90 . 4) (70 . 1) 
    (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1730.51 1790.41) (40 . 0.0) (41 . 0.0) (42 
    . 0.0) (91 . 0) (10 2769.28 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) 
    (10 2769.28 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1730.51 
    1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))
    but all my points are on DFX 10. How can I get them seperaly ?

  8. #8
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Quote Originally Posted by CadFrank View Post
    Thank alot! works like a charm.

    But now I Have a new question

    I want to get all the 2d points of my rectangle (rec3)

    but all my points are on DFX 10. How can I get them seperaly ?
    Some foods for thoughts .

    One way ...
    Code:
    (if (and (setq s (car (entsel "\n Select Lwpolyline :")))
             (member (cdr (assoc 0 (entget s)))
                     '("LWPOLYLINE" "POLYLINE")
             )
        )
      (foreach dxf (entget s)
        (if (eq (car dxf) 10)
          (setq pts (cons dxf pts))
        )
      )
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,743

    Default

    Quote Originally Posted by CadFrank View Post
    I want to get all the 2d points of my rectangle (rec3) but all my points are on DFX 10. How can I get them seperaly?
    http://www.cadtutor.net/forum/showth...l=1#post500564
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  10. #10
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2011
    Posts
    222

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Tharwat View Post
    Some foods for thoughts .

    One way ...
    Well I made it work with my code and now it gives me an error

    Code:
    ; error: bad argument type: lentityp ((-1 . <Entity name: 7fffed72540>) (0 . "LWPOLYLINE") (330 . <Entity name: 7fffed379f0>) (5 . "2BC") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "-LU SYMBOLE") (62 . 61) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1730.51 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1730.51 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))
    But I can't seem to pin point where it's from.

    Can I get a little more help so i can understand the error pretty plz

Similar Threads

  1. change the Width factor
    By e.mounir in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 5th Jan 2011, 12:56 pm
  2. changing global width of a rectangle
    By lesliematt in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 9th Jul 2010, 05:29 pm
  3. Change pline width within blocks
    By yrnomad in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 15th Jan 2010, 07:33 pm
  4. Problem-PLINE with width looks like a rectangle.
    By Joan_Ray in forum AutoCAD General
    Replies: 1
    Last Post: 30th Mar 2009, 12:55 pm
  5. How to change the width of the line
    By stargirl in forum AutoCAD General
    Replies: 6
    Last Post: 9th Jan 2004, 02:13 pm

Bookmarks

Posting Permissions

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