Jump to content

Recommended Posts

Posted

I have a lisp file that I cannot run for some reason.

 

This is an old lisp routine that I have run before some years ago.

 

I would appreciate if someone could work out for me the code that activates the lisp routine. I have tried the presumed code which is vertsightH100V10 and I receive an unknown comand message.

 

Perhapse this is a different version of AutoCAD i.e. 2010.

 

Best Regards

Bsimpson

 

(defun vk_GetPerpAng (CurveObj Dist)
 ((lambda (d)
    (if (zerop (cadr d))
      pi
      (+ (atan (apply '/ d))
  (/ pi
     (if (minusp (cadr d))
       -2
       2
     )
  )
      )
    )
  )
   (cdr
     (reverse
(vlax-curve-getFirstDeriv CurveObj (vlax-curve-getParamAtDist CurveObj Dist))
     )
   )
 )
)
(defun vertsightH100V10 (/
     Dist
     EndDist
     EndPoint
     Fuzz
     LineLen
     MinDist
     PathObj
     Perp1Len
     Perp2Len
     Point1
     Point2
     StartDist
     StartPoint
     Step
    )
 (princ "\nSelect PATH: ")
 (setq PathObj (vlax-ename->vla-object (car (entsel))))
 (setq EndDist   (vlax-curve-getDistAtParam PathObj (vlax-curve-getEndParam PathObj))
Fuzz   0.01      ; accuracy
Perp1Len  10.5
Perp2Len  1.5
LineLen   65.0
Step   3.0
StartDist 0.0
MinDist   (sqrt (- (expt LineLen 2) (expt (- Perp1Len Perp2Len) 2)))
Dist   MinDist
 )
 (while (< Dist EndDist)
   (setq Point1 (polar (setq StartPoint (vlax-curve-getPointAtDist PathObj StartDist))
  (vk_GetPerpAng PathObj StartDist)
  Perp1Len
  )
   )
   (while
     (and (< Dist EndDist)
   (< (distance
 Point1
 (setq Point2 (polar (setq EndPoint (vlax-curve-getPointAtDist PathObj Dist))
       (vk_GetPerpAng PathObj Dist)
       Perp2Len
       )
 )
      )
      LineLen
   )
     )
      (setq Dist (+ Dist Fuzz))
   )
   (if (< Dist EndDist)
     (progn (progn (entmake (list (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 4)
      (cons 10 StartPoint)
      (cons 10 Point1)
      (cons 10 Point2)
      (cons 10 EndPoint)
       )
     )
     )
     (setq StartDist (+ StartDist Step)
    Dist      (+ Dist Step)
     )
     )
   )
 )
 (vlax-release-object PathObj)
 (princ)
)

Posted

This is not a comand , is a function!

A function name is entered in parentheses, try (vertsightH100V10)

Posted

When you load the Lisp into AutoCAD - does it say anything on the command line?

Posted

Just create an acaddoc.lsp file into AutoCAD's Support folder (see here) and paste the code below along with the one you posted above into it; this will add a new command named vertsightH100V10.

 

(defun c:vertsightH100V10()
(vertsightH100V10)
(princ)
)

(princ)

 

Regards,

Posted

The lsp function worked once but now the function has the following error :

 

 

error: no function definition: VLAX-ENAME->VLA-OBJECT

 

Any idea what this means

Posted

Perhaps include

 

(vl-load-com)

 

at the top of the LISP :)

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...