Jump to content

lines perpendicular to spline


ysand

Recommended Posts

Hello everyone.

 

I've been looking at this old thread:

http://www.cadtutor.net/forum/showthread.php?5953-lines-perpendicular-to-spline

 

I need to use that code, but i can't seem to be able to do it, because of all the "&@40;" stuff (from what i can tell at least).

 

Can someone re-make that last code from post #8, in a form so i can copy it, because I am less than a newbie in lisp. :oops:

 

Thank you in advance.

Link to comment
Share on other sites

ysand,

 

The format of the post has been changed ( probably due to being archived ) to ASCII decimal.

 

You can do global search and replace in a text editor -

 

Replace:

 

(

With

(

 

 

)

With

)

 

You can use the ascii dec chart as a guide to what each value is as a character.

 

Remember to save the file as a true ascii file. -David

 

http://www.asciitable.com/

Link to comment
Share on other sites

Ok, this now works perfectly, but:

 

I need it to work not only on the spline points existing, but in spaces i choose on the spline.

I mean, i tried converting it to a polyline to have the points i want, but it doesn't work with polyline.

If anyone could help i'd appreciate it a lot.

Link to comment
Share on other sites

I use this...

 

(defun c:LPer (/ *error* ent pt)
 ;; Draw line perpendicular from selected curve
 ;; Required Subroutines: AT:GetSel
 ;; Alan J. Thompson, 09.29.09 / 12.20.10

 (vl-load-com)

 (defun *error* (msg)
   (and ent (redraw ent 4))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (if (setq ent
            (car (AT:GetSel
                   entsel
                   "\nSelect curve: "
                   (lambda (x)
                     (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getEndParam (list (car x))))
                     )
                   )
                 )
            )
     )
   (progn
     (redraw ent 3)
     (while (setq pt (getpoint "\nSpecify point for line: "))
       (entmake
         (list '(0 . "LINE")
               (cons 10 (vlax-curve-getClosestPointToProjection ent (trans pt 1 0) '(0 0 1)))
               (cons 11 (trans pt 1 0))
         )
       )
     )
   )
 )
 (*error* nil)
 (princ)
)

(defun AT:GetSel (meth msg fnc / ent good)
 ;; meth - selection method (entsel, nentsel, nentselp)
 ;; msg - message to display (nil for default)
 ;; fnc - optional function to apply to selected object
 ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
 ;; Alan J. Thompson, 05.25.10
 (setvar 'errno 0)
 (while (not good)
   (setq ent (meth (cond (msg)
                         ("\nSelect object: ")
                   )
             )
   )
   (cond
     ((vl-consp ent)
      (setq good (cond ((or (not fnc) (fnc ent)) ent)
                       ((prompt "\nInvalid object!"))
                 )
      )
     )
     ((eq (type ent) 'STR) (setq good ent))
     ((setq good (eq 52 (getvar 'errno))) nil)
     ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again.")))
   )
 )
)

Link to comment
Share on other sites

Hmm, are u sure the code is correct?

Couldn't make it work.

Quite sure, I use it all the time. Perhaps you could share what happened when you couldn't make it work.
Link to comment
Share on other sites

Ok, i might be doing it wrong.

 

I make an .lsp file with this code.

I open autocad, go to autolisp and load the file.

Then i type LPer as a command, and nothing.

Link to comment
Share on other sites

Are you shure you made the extension *.lsp??

 

--> YOu can also save the file to eg your desktop and then drag it into the autocad screen and release it. THen it loads too. It should work.

Link to comment
Share on other sites

I guess i pasted the code wrong.

It seems to work now.

 

Thanx a million alan :)

 

Can you please explain how exactly it works? The numbers i'm placing are the distance each perpendicular line is drawn from the previous one? I have to lengthen or shorten them manually?

Link to comment
Share on other sites

I guess i pasted the code wrong.

It seems to work now.

 

Thanx a million alan :)

 

Can you please explain how exactly it works? The numbers i'm placing are the distance each perpendicular line is drawn from the previous one? I have to lengthen or shorten them manually?

The length is based on the distance from the picked point.

 

How are you determining where on the curve to select for perpendicular line placement?

Link to comment
Share on other sites

So, i pick a point (i.e. the one end of the spline) and then if i want each perpendicular line every 1 unit, i type 1,2,3,4,5 etc? They just will be longer the farther i go?

Link to comment
Share on other sites

How are you determining where on the curve to select for perpendicular line placement?

 

I click on the edge of the spline, and then i type the number of units i want each perpendicular line to be drawn at.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...