+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 30
  1. #11
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,350

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by KRBeckman View Post
    I might be missing something here, but would it be possible to take the points taken from the polyline and save them as pt1, pt2, pt3.... so they can be used in another command?
    Wow... this is an old thread - takes me back to when I started learning all this..

    As for your question - all the point data is in the resulting list, so you could assign your variables from that.

    But I would approach it differently and use vlax-curve-getPointatParam as you have much more control.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  2. #12
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    200

    Default

    I tried to search Visual Lisp's help and google for this and I can only find examples of it being used that went way over my head... do you mind showing me an example of using this function and break it down step by step how it works?

  3. #13
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,350

    Default

    Each curve object is 'divided' by a parameter, you can look at it as the parameter in a set of parametric equations that would describe the curve if you like, so for a circle:

    Code:
    x = r cos(t)
    y = r sin(t)
    Where, in this case, t is the parameter.

    The curve functions allow you to get a point for a specific parameter value.

    In the case of LWPolylines, each segment spans between two integer values of the parameter, hence each vertex is at an integer parameter value.

    This gives you a lot of control when getting specific parameter values, as you can just 'count' the vertices.

    Example:

    Code:
    (defun c:test (/ ent i pt)
      (setvar "PDMODE" 34)
      
      (if (setq ent (car (entsel "\nSelect LWPolyline: ")))
        (progn
    
          (setq i (1- (vlax-curve-getStartParam ent)))
    
          (while (setq pt (vlax-curve-getPointatParam ent (setq i (1+ i))))
    
            (entmakex (list (cons 0 "POINT") (cons 10 pt))))))
    
      (princ))
    Last edited by Lee Mac; 9th Feb 2010 at 09:02 pm.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #14
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    804

    Default

    A long winded example.
    Code:
    (defun c:test (/ ent idx pt startParam endParam)
      (setvar "PDMODE" 34)
      
      (if (setq ent (car (entsel "\nSelect LWPolyline: ")))
        (progn
          (setq startParam (vlax-curve-getStartParam ent))  ; this is usually zero
          (setq endParam (vlax-curve-getEndParam ent))
          (setq idx startParam)
          (while (<= idx endParam) ; loop until we get to the last param
    	(setq pt (vlax-curve-getPointatParam ent idx))
            (entmakex (list (cons 0 "POINT") (cons 10 pt)))
    	(cond
    	  ((= idx endParam)
    	   (setq idx (1+ idx)) ; force an exit of the loop
    	   )
    	  
    	  ((> (setq idx (1+ idx)) ; next param
    	      endParam) ; test to see of we are past the end Param
    	    (setq idx endParam) ; in case the last param is a fraction
    	  )
    	)
          )
         )
      )
      (princ)
    )

  5. #15
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    200

    Default

    Wow, way over my head, I still have a lot to learn

  6. #16
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,350

    Default

    Quote Originally Posted by KRBeckman View Post
    Wow, way over my head, I still have a lot to learn
    I would recommend persevering with the curve-functions, they are a handy (and quick!) asset in your toolbox
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #17
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    200

    Default

    So, I've looked into this a bunch and I'm not getting anywhere... How would I use the vlax-curve-getPointatParam function to save the vertices as pt1, pt2, pt3....?

  8. #18
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    804

    Default

    All you need is a LIST of points, correct?

    This returns a list of points from the entity list of a LWPolyline.
    Code:
    (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
    Use it like this:
    Code:
    (defun c:test()
      (setq ent (car(entsel "\nSelect a polyline.")))
      (setq elst (entget ent))
      (setq PointList (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst)))
      (princ)
    )
    You don't need to assign each point to a variable.
    Tell us what you want to do with these points.

  9. #19
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    200

    Default

    Code:
    (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst))
    Yeah, I've gotten this far...


    Tell us what you want to do with these points.
    I want to use these points in filling the Polyline with 3d-Faces

  10. #20
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,350

    Default

    Registered forum members do not see this ad.

    Wasn't this being addressed here?

    http://www.cadtutor.net/forum/showthread.php?t=44611
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Increase vertex of 3dmesh
    By MR MAN in forum AutoCAD 3D Modelling & Rendering
    Replies: 6
    Last Post: 11th Sep 2008, 03:20 pm
  2. add vertex z or elevation to points
    By gvlisnas in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 4th Aug 2007, 11:14 pm
  3. reading from vertex files
    By gib65 in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 1st Feb 2007, 06:35 am
  4. Viewing 3DSolid vertex
    By LeoRoncetti in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 2nd May 2006, 01:14 am
  5. newb! question - join polyline then fillet
    By pdlefief in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 10th Apr 2006, 09:32 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts