Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33

Thread: Stationing Autolisp routine

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

    Default Re: Stationing Autolisp routine


  2. #12
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    It seems just crazy to me that nobody has a lisp routine that will station a polyline (in the standard 0+00 format) where you can pick a polyline in MODEL space (at scale 1:1), you don't have to screw around with scales, and it will draw stations and tic marks at desired distances. I use Map3D. Gone are the good old days when I used Survcadd. Is anybody out there working for a civil engineering firm?????

  3. #13
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Quote Originally Posted by jim.buhrdorf214720 View Post
    It seems just crazy to me that nobody has a lisp routine that will station a polyline (in the standard 0+00 format) where you can pick a polyline in MODEL space (at scale 1:1), you don't have to screw around with scales, and it will draw stations and tic marks at desired distances. I use Map3D. Gone are the good old days when I used Survcadd. Is anybody out there working for a civil engineering firm?????
    You may want to use this one from my oldies
    Code:
    ;; written by Fatty T.O.H. ()2004 * all rights removed
    ;; edited 6/5/10
    ;; edited 6/10/10
    ;; Stationing
    
    ;;load ActiveX library
    (vl-load-com)
    
    ;;local defuns
    
    ;//
    (defun makeblock (adoc aprompt atag bname txtheight tstyle / at_obj blk_obj lay line_obj tst)
    
    (if (not (tblsearch "block" bname))
      (progn
    
      (setq tst (getvar "textstyle"))
      (setvar "textstyle" tstyle)
      (setq lay (getvar "clayer"))
      (setvar "clayer" "0")
      
      (setq	blk_obj	(vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) bname))
      (setq line_obj (vlax-invoke blk_obj 'Addline '(0. 0. 0.) (list 0. 12.0 0.)))
      (vla-put-color line_obj acyellow)
      (setq at_obj (vla-addattribute blk_obj
    		 txtheight
    		 acattributemodeverify
    		 aprompt
    		 (vlax-3d-point '(-0.5 1. 0.))
    		 atag
    		 "0+00")
    	)
    
      (vla-put-rotation at_obj (/ pi 2))
      (vla-put-color at_obj acwhite)
      (mapcar (function (lambda(x) vlax-release-object x))
    	  (list at_obj line_obj blk_obj )
    	  )
      (setvar "clayer" lay)
      (setvar "textstyle" tst)
      )
      )
      )
    
    ;;//
    (defun start (curve)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getclosestpointto curve
      (vlax-curve-getstartpoint curve
        )
      )
    )
        )
      )
      )
    ;;//
    (defun end (curve)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getclosestpointto curve
      (vlax-curve-getendpoint curve
        )
      )
    )
        )
      )
      )
    ;;//
    (defun pointoncurve (curve pt)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getclosestpointto curve
      pt
        )
      )
    )
        )
      )
    ;;//
    (defun paramatpoint (curve pt)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getparamatpoint curve
      pt
        )
      )
    )
        )
      )
    ;;//
    (defun distatpt (curve pt)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getdistatpoint curve
        (vlax-curve-getclosestpointto curve pt)
        )
      )
    				)
        )
      )
    ;;//
    (defun pointatdist (curve dist)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getclosestpointto curve
      (vlax-curve-getpointatdist curve dist)
        )
      )
    )
        )
      )
    ;;//
    (defun curvelength (curve)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getdistatparam curve
      (- (vlax-curve-getendparam curve)
         (vlax-curve-getstartparam curve)
        )
      )
      )
    )
        )
      )
    ;;//
    (defun distatparam (curve param)
      (vl-catch-all-apply (function (lambda()
      (vlax-curve-getdistatparam curve
      param
      )
      )
    				)
        )
      )
    ;;//
    (defun statlabel  (num step div)
      ;; num - integer, zero based
      ;; step - double or integer, must be non zero
      
      (strcat
        (itoa (fix (/ num div)))
        "+"
        (if (zerop (rem num div))
          "00"
          (rtos (* (rem num div) step) 2 0))
    
        )
      )
    
    
    ;;//
    (defun insertstation (acsp bname pt rot tag num step div / block)
      (vl-catch-all-apply
        (function (lambda()
         (setq block (vlax-invoke-method acsp 'InsertBlock pt bname 1 1 1 rot))
    		)
    	      )
        )
      (changeatt block tag (statlabel num step div))
    
    block
      )
    
    ;;//
    (defun changeatt (block tag value / att)
      (setq atts (vlax-invoke block 'GetAttributes))
      (foreach att atts
        (if (equal tag (vla-get-tagstring att))
          (vla-put-textstring att value)
          )
        )
        )
    
    ;;// written by VovKa (Vladimir Kleshev)
    (defun gettangent (curve pt)
      
    	 (setq param (paramatpoint curve pt)
    	       ang ((lambda (deriv)
    		   (if (zerop (cadr deriv))
    		     (/ pi 2)
    		     (atan (apply '/ deriv))
    		   )
    		 )
    		  (cdr (reverse
    			 (vlax-curve-getfirstderiv curve param)
    		       )
    		  )
    		)
    )
      ang
      )
    
    ;;// main program
    (defun c:STAN (/ *error* acsp adoc block cnt div en ent label
    	       lastp lay leng lnum mul num pt rot sign start step)
      
      (defun *error* (msg)
        (if msg (princ (strcat "\nError! " msg)))
        (princ)
        )
      
      (setvar "dimzin" 4)
      (setq lay (getvar "clayer"))
      (setvar "clayer" "0")
      (setq adoc	(vla-get-activedocument (vlax-get-acad-object))
    	   acsp	(vla-get-block (vla-get-activelayout adoc))
         )
      
     (if (not (tblsearch "block" "Station"))
       (makeblock adoc "NUMBER" "NUMBER" "Station" 2.0 "Standard")
       )
      
     (while	(not
    	  (and
    	    (or
    	      (initget 6)
    	      (setq step (getreal "\nEnter step <25>: "))
    	      (if (not step)
    		(setq step 25.)))
    	    (zerop (rem 100 step))))
       (alert (strcat "\nRemainder 100 / " (rtos step 2 2) " is not equal to zero
    		  \nEnter correct step"))
       )
    
    
    (if
    
      (setq
        ent	(entsel
    	  "\nSelect curve near to the start point >>"
    	  )
        )
    
       (progn
    
         (setq en	(car ent)
    	   pt	(pointoncurve en (cadr ent))
    	   leng	(distatparam en (vlax-curve-getendparam en))
    	   )
    
         (setq num (fix (/ leng step))
    	   )
    
         (setq div (fix (/ 100. step)
    		    )
    	   )
    
         (setq mul (- leng
    		  (* (setq lnum (fix (/ leng (* step div)))) (* step div))))
    
         (if (not (zerop mul))
           (setq lastp T)
           (setq lastp nil)
           )
    
         (if (> (- (paramatpoint en pt)
    	       (paramatpoint en (vlax-curve-getstartpoint en))
    	       )
    	    (- (paramatpoint en (vlax-curve-getendpoint en))
    	       (paramatpoint en pt)
    	       )
    	    )
           (progn
    	 (setq start leng
    	       sign  -1
    	       )
    	 )
           (progn
    
    	 (setq start (distatparam en (vlax-curve-getstartparam en))
    	       sign  1
    	       )
    	 )
           )
    
    
         (vla-startundomark
           (vla-get-activedocument (vlax-get-acad-object))
           )
         (setq cnt 0)
         (repeat (1+ num)
           (setq pt	 (pointatdist en start)
    	     rot (gettangent en pt)
    	     )
    
           (setq block
    	      (insertstation
    		acsp
    		"Station"
    		(vlax-3d-point pt)
    		rot
    		"NUMBER"
    		cnt
    		step
    		div)
    	     )
    
    
           (setq cnt   (1+ cnt)
    	     start (+ start (* sign step))
    	     )
           )
    
    
         (if lastp
           (progn
    
    	 (if (= sign -1)
    	   (progn
    	     (setq pt  (vlax-curve-getstartpoint en)
    		   rot (gettangent en pt)
    		   )
    	     )
    	   (progn
    	     (setq pt  (vlax-curve-getendpoint en)
    		   rot (gettangent en pt)
    		   )
    	     )
    	   )
    	 (setq block
    		(insertstation
    		  acsp
    		  "Station"
    		  (vlax-3d-point pt)
    		  rot
    		  "NUMBER"
    		  (1- cnt)
    		  0
    		  div)
    	       )
    
    	 (setq label (strcat (itoa lnum) "+" (rtos mul 2 2))
    	       )
    	 (changeatt block "NUMBER" label)
    	 )
           )
         (setvar "clayer" lay)
         (vla-endundomark
           (vla-get-activedocument (vlax-get-acad-object))
           )
         )
       (princ "\nNothing selected")
       )
      (*error* nil)
    (princ)
    )
    
    (prompt "\n   >>>   Type STAN to execute...")
    (prin1)
    ~'J'~

  4. #14
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Thanks, Fixo!

  5. #15
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    You wouldn't happen to have the .lsp file? "STAN" at command line will not work - "STANDARDS" pops up as default. Also, do you have to have special tic and/or stationing text blocks either inserted into the drawing or in the same folder as the drawing? Thank you!

  6. #16
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Jim,
    I need more detail. An image or a copy of the drawing would be make a sense.

    ~'J'~

  7. #17
    Woo! Hoo! my 1st post
    Join Date
    2012-07
    Posts
    1
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Mr. Fixo Thanks for this codes... can you modify this to show 0+000 instead of 0+00..thanks a lot!!!

  8. #18
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    [OffTopic]

    Oleg, my friend -

    I just noticed the number of vlax-Curve-* calls in your code above; you may find this thread to be of particular interest.

    [/OffTopic]
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #19
    I could stop if I wanted to CadDog's Avatar
    Join Date
    2005-06
    Location
    So Ca
    Posts
    439
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Quote Originally Posted by aaronic_abacus View Post
    Here's a stationing autolisp routine I created before learning SoftDESK(land desktop).
    (see attachments)

    Code:
    (DEFUN C:SM (/ LP BP LOP LUP SLPS SLEN SLPP SLNPP SLEPP SLLA SLL CL SL NO SMN XS EV1 EVS SV EV2 PEP1 PEP2 FIP MARK NMSS DBO ISMN DBF LOOP IP RA PM SMSP SMSS SMS JC1 JC2 JS FLTR)
      (SETQ DBO 0)
      (SETQ ISMN 0)
      (SETQ NO NIL)
      (PROMPT "*STATION MARK*")
      (SETQ LP 1)
      (WHILE LP
        (SETQ BP (GETPOINT "\nPick first station location: "))
        (SETQ BP (OSNAP BP "NEA"))
        (IF	(/= BP NIL)
          (SETQ LP NIL)
          (PROMPT " POINT NOT ON STATION LINE ")
        )
      );END WHILE LP
      (SETQ LUP 1)
      (WHILE LUP
        (SETQ LOP 1)
        (WHILE LOP
          (SETQ SLPS (ENTSEL "\nSelect station line: "))
          (IF (/= SLPS NIL)
    	(SETQ LOP NIL)
    	(PROMPT " NO OBJECT SELECTED ")
          )
        );END WHILE LOP
        (SETQ SLEN (CAR SLPS))
        (IF	(= (CDR (ASSOC 0 (ENTGET SLEN))) "LWPOLYLINE")
          (SETQ LUP NIL)
          (PROMPT " OBJECT SELECTED NOT A POLYLINE ")
        )
      );END WHILE LUP
      (SETQ SLPP (CADR SLPS))
      (SETQ SLNPP (OSNAP SLPP "NEA"))
      (COMMAND "BREAK" SLNPP "F" BP BP)
      (SETQ SLEN (SSNAME (SSGET SLNPP) 0))
      (SETQ SLLA (ASSOC 8 (ENTGET SLEN)))
      (SETQ SLL (CDR SLLA))
      (SETQ CL (GETVAR "CLAYER"))
      (SETVAR "CLAYER" SLL)
      (SETQ SMN (GETREAL "\nStarting station mark # <0>: "))
      (IF (= SMN NIL)
        (SETQ SMN 0)
      )
      (INITGET "A D")
      (SETQ NO (GETKWORD "\nDescend <Ascend>: "))
      (IF (= NO NIL)
        (SETQ NO "A")
      )
      (SETQ SL (GETREAL "\nStation segment length <50>: "))
      (IF (= SL NIL)
        (SETQ SL 50.0)
      )
      (PROMPT "\nSymbol scale <")
      (PRINC DWGSCALE)
      (PROMPT ">: ")
      (SETQ XS (GETREAL))
      (IF (= XS NIL)
        (SETQ XS DWGSCALE)
      )
    
      (SETQ SLENL (ENTGET SLEN))
      (SETQ EV1 (CDR (ASSOC 10 SLENL)))
      (SETQ EVS EV1)
      (SETQ SV 1)
      (WHILE SV
        (SETQ SLENL (CDR SLENL))
        (SETQ EVT (ASSOC 10 SLENL))
        (IF	(/= EVT NIL)
          (SETQ EV2 (CDR EVT))
          (SETQ SV NIL)
        )
      );END WHILE SV
      (SETQ PEP1 EV1)
      (SETQ PEP2 EV2)
      (IF (> (DISTANCE SLNPP PEP2) (DISTANCE SLNPP PEP1))
        (SETQ FIP PEP1)
        (SETQ FIP PEP2)
      )
    
      (COMMAND "INSERT" "MARK" FIP XS "" SLNPP)
      (SETQ MARK (ENTLAST))
      (COMMAND "REGENAUTO" "OFF")
      (COMMAND "MEASURE" SLNPP "B" "MARK" "Y" (* SL 12))
      (SETQ NMSS (SSLENGTH (SSGET "P")))
      (IF (> (DISTANCE FIP (CDR (ASSOC 10 (ENTGET (ENTNEXT MARK)))))
    	 (+ (* SL 12) 1)
          )
        (PROGN (SETQ DBO 1) (SETQ ISMN 1))
        (SETQ DBO 0)
      )
      (COMMAND "POINT" "@")
      (SETQ DBF (ENTLAST))
      (COMMAND "SETVAR" "ATTREQ" "0")
      (SETQ LOOP 1)
      (WHILE LOOP
        (SETQ ELIST (ENTGET MARK))
        (SETQ IP (CDR (ASSOC 10 ELIST)))
        (SETQ RA (/ (* 180 (CDR (ASSOC 50 ELIST))) PI))
        (SETQ RA (- RA (* (FIX (/ RA 360)) 360)))
        (IF	(AND (> RA 90) (< RA 270))
          (SETQ RA (+ RA 180))
        )
        (SETQ PM MARK)
        (SETQ MARK (ENTNEXT MARK))
        (COMMAND "ERASE" PM "")
        (COMMAND "INSERT" "STMK" IP XS "" RA)
        (SETQ SMSP (FIX (/ SMN 100)))
        (SETQ SMSS (- SMN (* SMSP 100)))
        (IF	(< SMSP 0)
          (SETQ SMSP (* -1 SMSP))
        )
        (IF	(< SMSS 0)
          (SETQ SMSS (* -1 SMSS))
        )
        (IF	(= SMSS 0)
          (SETQ SMSS "00")
          (SETQ SMSS (RTOS SMSS 2 0))
        )
        (SETQ SMSP (RTOS SMSP 2 0))
        (SETQ SMS (STRCAT SMSP "+" SMSS))
        (COMMAND "ATTEDIT" "N" "N" "STMK" "STMK" "STMK" "STMK" SMS)
        (IF	(AND (= ISMN 1) (= NO "A"))
          (PROGN (SETQ SMN (+ (+ (* NMSS SL) SMN) SL)) (SETQ ISMN 0))
        )
        (IF	(AND (= ISMN 1) (= NO "D"))
          (PROGN (SETQ SMN (- SMN (+ (* NMSS SL) SL))) (SETQ ISMN 0))
        )
        (IF	(AND (= DBO 1) (= NO "A"))
          (SETQ SMN (- SMN SL))
        )
        (IF	(AND (= DBO 0) (= NO "A"))
          (SETQ SMN (+ SMN SL))
        )
        (IF	(AND (= DBO 1) (= NO "D"))
          (SETQ SMN (+ SMN SL))
        )
        (IF	(AND (= DBO 0) (= NO "D"))
          (SETQ SMN (- SMN SL))
        )
        (IF	(= (CDR (ASSOC 0 (ENTGET MARK))) "POINT")
          (SETQ LOOP NIL)
        )
      );END WHILE
      (SETQ JC1 (MAPCAR '+ BP '(0.01 0.01 0.0)))
      (SETQ JC2 (MAPCAR '- BP '(0.01 0.01 0.0)))
    
      (SETQ
        FLTR (LIST '(-4 . "<AND") SLLA '(0 . "POLYLINE") '(-4 . "AND>"))
      )
      (SETQ JS (SSGET "C" JC1 JC2 FLTR))
      (COMMAND "PEDIT" SLEN "J" JS "" "X")
      (COMMAND "SETVAR" "ATTREQ" "1")
      (COMMAND "REGENAUTO" "ON")
      (COMMAND "ERASE" DBF "")
      (SETVAR "CLAYER" CL)
      (PRINC)
    );END SM
    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Thanks aaronic_abacus for your code.

    With a little adjustment I was able to get it to work for civil plans...
    Civil 3D is cool but sometime I like to work fast without messing around with all the tabs they have.

    Here are a few things I changed...
    (SETQ DWGSCALE (GETVAR "DIMSCALE"))

    I don't need to work your sas by adding this...

    (COMMAND "MEASURE" SLNPP "B" "MARK" "Y" (* SL 1)) ;WAS SET TO 12

    (IF (> (DISTANCE FIP (CDR (ASSOC 10 (ENTGET (ENTNEXT MARK)))))
    (+ (* SL 1) 1);change from 12 to 1
    This now works on civil full size plans.

    That is it... I'm going to try to place tangent lines with stationing next.

    Thanks again for this base code it is great of you to share...

  10. #20
    Member
    Join Date
    2013-10
    Location
    South Carolina
    Posts
    3
    Login to Give a bone
    0

    Default Re: Stationing Autolisp routine

    Hey, I'm a newbie to using lsp files, and need some addtional info on how to run this lsp. I would like to be able to place station markers on a polyline.

    My question is "what do I type in my command line to load the lsp?"

    I'm running plain jane AutoCAD 2012. I put the attachments in a folder that AutoCAD can access, I just did not see a load command. I tried (load "*station mark*") and that did not work for me. I got ;error: load failed: "*station mark*"

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2014-04-15, 06:15 PM
  2. Routine to Play Winamp via AutoLISP
    By Adesu in forum AutoLISP
    Replies: 0
    Last Post: 2007-02-08, 01:36 AM
  3. Select Similar Autolisp routine
    By VBOYAJI in forum AutoLISP
    Replies: 9
    Last Post: 2006-06-28, 05:31 PM
  4. Please help with Autolisp routine about Printing
    By Matt Mercer in forum AutoLISP
    Replies: 9
    Last Post: 2006-03-09, 03:27 PM
  5. HELP: need to run 2 Autolisp routine at a time
    By bradipos in forum AutoLISP
    Replies: 0
    Last Post: 2004-09-28, 01:06 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
  •