See the top rated post in this thread. Click here

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

Thread: rotate function in lisp not working, but worked in older version

  1. #1
    I could stop if I wanted to Hammer.John.J's Avatar
    Join Date
    2015-09
    Location
    Springfield, MA
    Posts
    491
    Login to Give a bone
    0

    Default rotate function in lisp not working, but worked in older version

    This lisp routine I have used for ages but skipped a view versions and I'm trying to use with 2018 and 2021 is no longer functioning as it used to. The expected functionality is during the block placement, we pick a second point using the nearest osnap to align the block with the line so that the block is aligned with 2nd point we pick and then the block is inserted. Any help is greatly appreciated.

    Code:
    ;|Routine to label contours drawn by Line/Arc/Polyline. Originally penned by
      CiphDRMRS, aka T.Willey, on the AUGI Forums. Modified by Jeff Mishler.
      An assumption is made that a valid block with 1 attribute is selected.
      |;
    (vl-load-com)
    
    (defun c:CLB ( / *error* osz atq atd cmd e p)
      
      (defun *error* (errmsg)
        (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
          (princ (strcat "\nError: " errmsg)))
        (if osz (setvar 'osnapz osz))
        (if atq (setvar 'attreq atq))
        (if atd (setvar 'attdia atd))
        (if cmd (setvar 'cmdecho cmd))
        (princ))
      
      
      (setq osz (getvar 'osnapz))  	(setvar 'osnapz 0)
      (setq atq (getvar 'attreq))   (setvar 'attreq 0)
      (setq atd (getvar 'attdia))   (setvar 'attdia 0)
      (setq cmd (getvar 'cmdecho))  (setvar 'cmdecho 0)
      
      (while (and (setq p (getpoint "\nPlace a label: "))
    	      (setq e (car (nentselp p))))
        
        (command "_.insert" "CL3-20"
    	     "_S" 1
    	     "_R" (angtos (angle '(0 0 0) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e (vlax-curve-getclosestpointto e p)))) (getvar 'aunits) 8)
    	     "_nea" p)
        (setpropertyvalue (entlast) "CLAB" (rtos (last p) 2 0)))
      (*error* "end")
      )
    Last edited by Hammer.John.J; 2022-08-05 at 07:53 PM.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    1

    Default Re: rotate function in lisp not working, but worked in older version

    You might also want to attach a dwg that is set up for testing.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    There's been a lot of changes to the INSERT command in recent years, looking at the help links below it may be hard to modify the lisp to work in both 2018 and 2022.

    2018 INSERT (Command)

    2022 INSERT (Command)

    2022 -INSERT (Command)

    2022 CLASSICINSERT (Command)

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    Quote Originally Posted by Ed Jobe View Post
    You might also want to attach a dwg that is set up for testing.
    I have a routine that labels contour elevations with multiline text with a background mask scaled to current annotation scale.
    It uses the Civil 3D command for Civil 3D contours, polyline elevations if they have them, and Elevation data if they were imported with Map 3D.

    Like Ed Jobe said we'd have to have a drawing we could test on.

  5. #5
    I could stop if I wanted to Hammer.John.J's Avatar
    Join Date
    2015-09
    Location
    Springfield, MA
    Posts
    491
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    example attached
    also i edited my post, i need it for 2021 which is the same dwg format as 2018, thanks.

    we cannot use background masks because of the mixing of grays through a myriad of xrefs, we need to use wipeouts and linesmerge thanks
    Attached Files Attached Files

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    Quote Originally Posted by Hammer.John.J View Post
    also i edited my post, i need it for 2021 which is the same dwg format as 2018, thanks.
    All the way to current 2023, the dwg format is still the same. What has changed are the command prompts. Different options.
    C:> ED WORKING....


    LinkedIn

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    Quote Originally Posted by Hammer.John.J View Post
    we cannot use background masks because of the mixing of grays through a myriad of xrefs, we need to use wipeouts and linesmerge thanks
    I've attached a modified drawing with two examples using multiline text with background masks set, one of them has the frame turned on.

    How would background masks display differently than wipeouts? Having to add a block complicates things.

    Going home now, have a nice weekend!
    Attached Files Attached Files

  8. #8
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    Maybe by editing your block.
    Keep the attribute, modify or create a multiline style with an offset of 0.9 and -0.9 and having outgoing arcs at the ends and a fill color of 255,255,255.
    With this type of multiline, simply draw a horizontal line on your attribute definition, if necessary put the drawing of it back in the foreground...

  9. #9
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    2

    Default Re: rotate function in lisp not working, but worked in older version

    Please try the following complete program and you need to specify your attributed block name as specified in the codes below.
    NOTE: The tag string that the program targets is the same one you have used into your posted codes so once you change the name of the attributed block then you need to change it as well if it is not matching to "CLAB".

    Code:
    (defun c:CLB (/ *error* bkn var val spc ins blk sel ent)
      ;; Tharwat Al Choufi.	- Date: 06.Aug.2022		;;
      ;; website: https://autolispprograms.wordpress.com	;;
      (defun *error* (msg)
        (and val (mapcar 'setvar var val))
        (and msg
             (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
             (princ (strcat "\nError => " msg))
        )
        (princ)
      )
      ;;				;;
      (setq bkn "CL2-20") ;; <<< specify your desired Attributed block name here.
      ;;				;;
      (and
        (or (tblsearch "BLOCK" bkn)
            (alert (strcat "Block name < " bkn " > was not found <!"))
        )
        (setq var '(osnapz attreq attdia)
              val (mapcar 'getvar var)
              spc (vlax-get (vla-get-activelayout
                              (vla-get-activedocument (vlax-get-acad-object))
                            )
                            'Block
                  )
        )
        (mapcar 'setvar var '(0 0 0))
        (while
          (and
            (setq ins
                   (getpoint
                     "\nSpecify a point on Line, Polyline object to place a label <enter to exit> : "
                   )
            )
            (or (and
                  (setq sel (ssget ins))
                  (wcmatch (cdr (assoc 0 (entget (setq ent (ssname sel 0)))))
                           "LINE,LWPOLYLINE"
                  )
                )
                (alert "Could not detect any Line & LWpolyline object <!>")
            )
          )
           (setq blk (vlax-invoke
                       spc
                       'insertblock
                       (vlax-curve-getclosestpointto ent ins)
                       bkn
                       1.
                       1.
                       1.
                       (angle '(0 0 0)
                              (vlax-curve-getFirstDeriv
                                ent
                                (vlax-curve-getParamAtPoint
                                  ent
                                  (vlax-curve-getclosestpointto ent ins)
                                )
                              )
                       )
                     )
           )
           (foreach att (vlax-invoke blk 'getattributes)
             (and (= (vla-get-tagstring att) "CLAB")
                  (vla-put-textstring att (rtos (caddr ins) 2 0))
             )
           )
        )
      )
      (*error* nil)
      (princ)
    ) (vl-load-com)

  10. #10
    I could stop if I wanted to Hammer.John.J's Avatar
    Join Date
    2015-09
    Location
    Springfield, MA
    Posts
    491
    Login to Give a bone
    0

    Default Re: rotate function in lisp not working, but worked in older version

    can't wait to test this thanks!!

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 10
    Last Post: 2018-05-14, 07:50 PM
  2. DLL plugin worked at first but now doesn't
    By rollinkuhn in forum Dot Net API
    Replies: 1
    Last Post: 2011-01-27, 08:44 PM
  3. Commands not supported in older Cad Version
    By gthree in forum Software
    Replies: 2
    Last Post: 2010-03-25, 12:29 PM
  4. Revision macro worked in 2002, but not in 2006!
    By kastmiler in forum AutoCAD Customization
    Replies: 3
    Last Post: 2006-11-05, 01:38 PM
  5. Why can't Revit export older version of DWG ????
    By Richard McCarthy in forum Revit Architecture - General
    Replies: 7
    Last Post: 2004-03-20, 07:12 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
  •