Results 1 to 3 of 3

Thread: StrikeThrough routine help

  1. #1
    Member
    Join Date
    2008-05
    Posts
    2
    Login to Give a bone
    0

    Default StrikeThrough routine help

    I am creating a quick and dirty routine to do a manual pline drawn Strike through of regular dtext entities.

    unfortunately I am having difficulty of getting the P1 and P2 points to Extend beyond the text by 1 character and centered in the text based on the alignment.
    It works as is for all caps but doesn't extend the full length,

    another problem is that when there are lower case characters, such as y,p,q etc. the strike through basis it's positioning on the overall text box.


    any suggestions?

    Code:
    (defun C:Strike ( / textent tb ll ur ul lrx1 y1 x2 y2 p1 p2)
    (setvar "CMDECHO" 0)
    (setq textent (car (entsel "\nSelect text: ")))
    (command "UCS" "ENTITY" textent)
    (setq tb (textbox (list (cons -1 textent)))
    ll (car tb)
    ur (cadr tb)
    ul (list (car ll) (cadr ur))
    lr (list (car ur) (cadr ll))
    ofs (* -2)
    x1 (car ll)
    y1 (cadr ll)
    x2 (car lr)
    y2 (cadr lr)
    x1 (- x1 ofs)
    y1 (- y1 ofs)
    x2 (+ x2 ofs)
    y2 (- y2 ofs)
    p1 (list x1 y1)
    p2 (list x2 y2)
    );setq
    ;;;use Ltscale as scaling factor.
    (command "LAYER" "s" "0" ""
    "PLINE" p1 "W" (* (getvar "LTSCALE") 0.0) "" p2 ""
    "UCS" "P"
    );command
    (princ)
    );defun
    (princ)
    Last edited by Opie; 2009-07-28 at 07:50 PM. Reason: [code] tages added

  2. #2
    Member
    Join Date
    2008-05
    Posts
    2
    Login to Give a bone
    0

    Default Re: StrikeThrough routine help

    got the results I was looking for.
    now to just add a
    function to
    explode mtext, cross out all the lines created from it,
    then use that selection set to use txt2mtext

    Code:
    (defun c:STRIKE (/ ang basept BxCoords entLst extend height length ocmd olderr ss txtEnt)
    (vl-load-com)
    (setq olderr *error*
    *error* myerror 
    ocmd (getvar "cmdecho")
    )
    (setvar "cmdecho" 0) 
    
    (setq ss (ssget "+.:E:S" '((0 . "TEXT"))) 
    )
    (defun dtr (a)
    (* pi (/ a 180.0))
    )
    (setq os (getvar "osmode"))
    (setvar "osmode" (logior os 16384))
    ;-----------------------------------------------------------------;
    (if ss
    (progn
    (setq txtEnt (ssname ss 0)
    entLst (entget txtEnt)
    basePt (cdr (assoc 10 entLst)) 
    BxCoords (textbox (list (cons -1 txtEnt)))
    height (cdr (assoc 40 entLst))
    extend (* height 0.15)
    length (caadr bxcoords) 
    ang (cdr (assoc 50 entLst))
    basept (mapcar '- basept (list extend 0 0))
    )
    (command "LAYER" "s" "Display_Note_R" "" "pline" (polar basept (+ (dtr 90) ang)(/ height 2))(polar (getvar "lastpoint") ang (+ length extend extend)) "") 
    ) ;
    ) ; 
    ;----------------------------------------------------------------; 
    (setq *error* olderr) ;resets error 
    (setvar "cmdecho" ocmd) 
    (setvar "osmode" os) ;resest osnaps if they were turned off back on
    (princ) ;no nil at end of program.
    ) ;end defun.
    Last edited by Opie; 2009-07-29 at 03:26 PM. Reason: [code] tags added

  3. #3
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: StrikeThrough routine help

    BTW, that's a pretty old-school way of treating the error handler. Not to mention that the redefined error handler is not even there (presuming you elected to not post it).

    Here is the approach many starting using once AutoCAD 2000 was released:

    Code:
    (defun MyExit (msg)
     (cond 
      ((not msg)) ; no error, normal exit
      ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
      ((princ (strcat "\nError: " msg)))) ; error, display it
      ;| any other code for needed cleanup |;
     (princ))
    
    (defun C:MainCode (/ *Error*) ; localize error handler
     (setq *Error* MyExit) ; redefine local error handler
     ;| rest of the main code |;
     (MyExit nil)) ; normal, clean exit
    This works because once AutoCAD 2000 came out, when a localized error handler runs, it remains local. Prior to 2000, when a localized error handler ran it would become global, overwriting the original global error handler. That is where the save old, set new, restore old approach came from. There is no need for that any longer.

    The other advantage to this later approach is that you need to write the clean code only once. The MyExit function can act in both an error situation or a normal exit, as long as you handle the msg argument as being nil in a normal exit.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

Similar Threads

  1. 2013: Strikethrough Text in Schedules / Sheetlist
    By ReachAndre in forum Revit MEP - General
    Replies: 2
    Last Post: 2013-02-27, 06:02 PM
  2. Replies: 1
    Last Post: 2010-11-18, 02:16 AM
  3. Replies: 2
    Last Post: 2007-04-20, 09:51 AM

Posting Permissions

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