Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Ah ha, mleaderstyle... thanks
Steve
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Great tool, works perfectly.
As it happens i'm using AutoCAD 2011 64bit, it's probably the 64bit that stopped the original solution. I've been trying to learn VBSCRIPT, it took me a week to just get it to debug on a 64bit machine, nobody said the language had changed.
Thankyou so much for your time.
AutoCAD Certified Professional
Win 7 Pro 64bit, Dell Precision M6500
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
GegH1,
You received the error because the Visual LISP extensions hadn't been loaded with (vl-load-com).
Most users include this in their ACADDOC.lsp so that the Visual LISP functions are always available for programs that use them. This function only need be called once per drawing session to ensure the Visual LISP extensions are available throughout the session, which makes more sense than calling the function for each loaded program.
Another way to approach it:
(defun c:test ( / e s p )
(if (setq s (ssget '((0 . "*POLYLINE"))))
(while (setq e (ssname s 0))
(vl-cmdf "_.mleader" "_non"
(setq p (trans (vlax-curve-getendpoint e) 0 1)) "_non"
(polar p (/ pi 4.) (* 4 (getvar 'DIMTXT)))
(itoa (1+ (fix (vlax-curve-getendparam e))))
)
(ssdel e s)
)
)
(princ)
)
(vl-load-com)
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Lee,
Thanks for that, The code seems a lot shorter.
It constantly amaizes me how many ways there are to skin a Cat in AutoCAD.
AutoCAD Certified Professional
Win 7 Pro 64bit, Dell Precision M6500
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Lee .
Your routine would consider the rectanle LWpolyline ( square shapes ) as five points . ![]()
Tharwat
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
@ GegH1,
You're very welcome ![]()
There are indeed many ways to approach the same problem with AutoCAD, especially since the drawing database can be accessed using both Vanilla AutoLISP and Visual LISP, providing effectively two interfaces for most entities. Of course, some things are easier manipulated using Vanilla (such as dictionaries), whilst others are only possible through VL.
@ Tharwat,
Good spot
This is because my code uses the value End Parameter (since the vertices of a Polyline have integer parameter values), however, my code didn't consider a closed polyline wherein the endpoint and startpoint are coincident.
This should fix that problem:
(defun c:test ( / e s p )
(if (setq s (ssget '((0 . "*POLYLINE"))))
(while (setq e (ssname s 0))
(vl-cmdf "_.mleader" "_non"
(setq p (trans (vlax-curve-getendpoint e) 0 1)) "_non"
(polar p (/ pi 4.) (* 4 (getvar 'DIMTXT)))
(itoa (+ (fix (vlax-curve-getendparam e)) (if (vlax-curve-isclosed e) 0 1)))
)
(ssdel e s)
)
)
(princ)
)
(vl-load-com)
Also, you might want to consider UCS for your code ![]()
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Lee_Mac wrote:Also, you might want to consider UCS for your code
Yeah ... that's right .
(**** for tat) ![]()
Thanks
Re: Polyline Vertex Counter
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
![]()
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper


