Help Required

Discussion in 'AutoCAD' started by Steve Rudd, Jan 22, 2004.

  1. Steve Rudd

    Steve Rudd Guest

    Hi,
    I have put this code to-gether which is intended to rescale existing block
    entities. However, when attributes are present, they are ignored and remain
    at the original size. What needs to be changed? Also, is the method I have
    used to obtain and revise the assoc codes of the inserts the most efficient?

    (defun c:resc()
    (setq a(ssget))
    (setq sc(getreal "\nEnter Drawing Scale :"))
    (setq n(sslength a))
    (setq index 0)
    (repeat n
    (setq b1 (entget(ssname a index)))
    (setq index (+ index 1))
    (setq b (assoc 0 b1))
    (if (= "INSERT" (cdr b))
    (progn
    (setq c1 (assoc 41 b1))
    (setq c2 (assoc 42 b1))
    (setq c3 (assoc 43 b1))
    (setq d1 (cons (car c1) sc))
    (setq d2 (cons (car c2) sc))
    (setq d3 (cons (car c3) sc))
    (setq b2 (subst d1 c1 b1))
    (setq b2 (subst d2 c2 b2))
    (setq b2 (subst d3 c3 b2))
    (entmod b2)
    );progn
    );if
    );repeat
    );defun

    Rgds, Steve
     
    Steve Rudd, Jan 22, 2004
    #1
  2. Steve Rudd

    Rune Wold Guest

    Block references (INSERT) with attribute references (ATTRIB) have their DXF
    code 66 set to 1.

    Using the ENTNEXT function on the entity name (DXF -1) of the INSERT gives
    you the entity name of the first ATTRIB. Then use ENTNEXT with the first
    ATTRIB's entity name to get the entity name of the second ATTRIB, and so on.
    Repeat until the returned entity is a SEQEND and you have all ATTRIBs that
    belong to your INSERT.

    Calculating the new size and position of each ATTRIB can be a pain, so if
    all your INSERTs are proportionally scaled (same scale factor for X, Y and
    Z), I'll recommend you use the SCALE command.

    Here's a quick example (watch for wrap):

    (defun C:ReScale (/ rScale ssEnt iCnt eprIns rRelScale)
    (if (setq ssEnt (ssget))
    (setq rScale (getdist "\nEnter Drawing Scale :"))
    )
    (if rScale
    (repeat (sslength ssEnt)
    (if (= (cdr (assoc 0 (setq eprIns (entget (ssname ssEnt (setq iCnt (if
    iCnt (1+ iCnt) 0))))))) "INSERT")
    (progn
    (if (= (cdr (assoc 41 eprIns)) (cdr (assoc 42 eprIns)) (cdr (assoc
    43 eprIns)))
    (progn
    (setq rRelScale (/ rScale (cdr (assoc 41 eprIns))))
    (command "._SCALE" (cdr (assoc -1 eprIns)) "" (cdr (assoc 10
    eprIns)) rRelScale)
    )
    )
    )
    )
    )
    )
    )

    I see you are not dimensioning local variables. This means that all your
    variables will be populated after the function has been run. Sooner or
    later, this will get you into trouble.

    And I'm a fan of Hungarian Notation...
     
    Rune Wold, Jan 22, 2004
    #2
  3. Steve Rudd

    urugx Guest

    Can't you not use the scale command.
    Just extract the insert point of the block
    and use the scale command. Then you
    don't have to worry about attributes.

    Sounds so simple, but may not be what
    you want.
     
    urugx, Jan 22, 2004
    #3
  4. Steve Rudd

    Steve Rudd Guest

    Rune,

    Thanx for your reply. The thought of using the scale command had not entered
    my head, even though I was using this command each time, manually.
    Your code has opened my eyes somewhat. I will learn from what you have done.
    Thank you so much.

    Rgds, Steve.
     
    Steve Rudd, Jan 22, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.