+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
  1. #1
    Full Member pryzmm's Avatar
    Computer Details
    pryzmm's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2009
    Join Date
    Jul 2007
    Posts
    54

    Question Re-draw an object using polyline from nodes created by "divide" command

    Registered forum members do not see this ad.

    hi, i'm still a beginner in lisp and need some help from you guys;

    ;;;----

    lets say i have a closed polyline outline (shape like a light bulb) that consist of lines and arc as my base entity.
    if i were to use "divide" say by "50 segments" (user input) on this polyline can this 50 nodes or more that has been created be use to trace the outline of the entity using "polyline" by lisp.

    i will then use this newly created closed polyline (all lines) to be the "wipeout" frame as we know that only close "polyline" (all lines) are accepted.

    i use acad (archi) 2009 (win xp)

    ;;;sequence summary
    ;;;--------------------------
    ; prepares the base entity using polyline (lines, arc) before lisp initiation.

    ;(defun c:dw () ; short for divide-wipeout
    ;(setq oldpdmode (getvar "pdmode"))
    ;(setq p1 (entsel "\n select entity") ; selection set p1
    ; ensure that the selection is a polyline otherwise alert the user and re-select.
    ;(command ".divide" p1 "ask user for input") ; divide command that will ask user on how many segment req.
    ; use the nodes/points that the ".divide" command created and begin "pline" command to trace those nodes and then close the pline.
    ; (command "wipeout" "p" entlast "y")
    ; deletes all the pdmode points
    ; (princ) exit cleanly
    ;;;--------------------------


    thank you in advance

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    4,008

    Default

    Try to parse the polyline parametrically using the required number of vertexes:

    Code:
    (setq MyPline (vlax-ename->vla-object (entlast))
          NrNodes 50)
     
    (setq Param1st   (vlax-curve-getStartParam MyPline)   ;parameter at start point
          Param2nd   (vlax-curve-getEndParam   MyPline)   ;parameter at end point
          ParamLen   (- Param2nd Param1st)                ;parametrical "length"
          DefameSize (/ ParamLen NrNodes))                ;size of defame
     
    (setq theCounter 0)
    (command "_PLINE")
    (repeat NrNodes
     (command (setq thePoint (vlax-curve-getPointAtParam MyPline (+ Param1st (* theCounter DefameSize)))))
     (setq theCounter (1+ theCounter))
    )
    (command "_Close")
    Regards,

  3. #3
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,084

    Default

    This modification close to yours.
    Code:
    (defun c:dw (/ oldpdmode ent )
    (setq oldpdmode (getvar "pdmode"))
    (setvar "pdmode" 66)
    (setq ent (entsel "\n select entity"))
    (command "_.divide" ent pause "")
     (command "_.wipeout" "_p" ent "y")
      (setvar 'pdmode oldpdmode)
    (princ)
    )
    Regards,

    Tharwat

  4. #4
    Full Member pryzmm's Avatar
    Computer Details
    pryzmm's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2009
    Join Date
    Jul 2007
    Posts
    54

    Default

    msasu -- thank you for your reply and suggestion, im really a newbie in lisp so your code is like chinese to me,, sorry could you explain more please on how to complete it,,

    tharwat -- thank you as well, my intention was to use the orig. outline as the guide to draw another p-line that will be created or rather traced using the divide command;; you see "wipeout" only accept "closed all lines polyline" (pls. correct me if im wrong) and my idea is by dividing the original outline with enough segment i could somehow mimic the original outline, then use the pline command to connect all the nodes with lines think of it like "connecting dots" but in this case a lisp has to draw that p-line and use the resulting polyline for the "wipeout" command,,,

    keep on coming guys

  5. #5
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,084

    Default

    You're welcome.

    If you want to to select a polyline then divide it into a number and create a polyline to connect all the points that are
    created by the divide command, I think it's not possible .

    Because the points or nodes are do not have a XYZ when they are being made by a command divide, so the polyline or a line
    either can't find the coordinate points to connect to.

    This is what I know about points up to this moment.

    Thanks

    Tharwat
    Last edited by Tharwat; 28th Jul 2010 at 03:59 pm.

  6. #6
    Full Member pryzmm's Avatar
    Computer Details
    pryzmm's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2009
    Join Date
    Jul 2007
    Posts
    54

    Default

    @tharwat, thanks once again,, i understand what you mean,, is there any other way i can do it with a similar result if "divide" is not possible?,,,

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    4,008

    Default

    @pryzmm: My example code is parsing a polyline parametrically and retrace it by a given number of points - it was intended to be added to your code. However I have joined those codes for you:

    Code:
    (defun c:PLtoW( / OldOsmode MyPline NrNodes Param1st Param2nd ParamLen DefameSize theCounter )
     (vl-load-com)
     (setq OldOsmode (getvar "OSMODE"))
    
     (prompt "\nSelect a closed polyline: ")
     (while (not (setq MyPline (ssget "_:S" '((0 . "LWPOLYLINE") (70 . 1))))) (princ "\nWrong selection! Try again."))
     (if (and MyPline
              (setq NrNodes (getint "\nNumber of vertexes: ")))
      (progn
       (setq MyPline (vlax-ename->vla-object MyPline))
     
       (setq Param1st   (vlax-curve-getStartParam MyPline)   ;parameter at start point
             Param2nd   (vlax-curve-getEndParam   MyPline)   ;parameter at end point
             ParamLen   (- Param2nd Param1st)                ;parametrical "length"
             DefameSize (/ ParamLen NrNodes))                ;size of defame
     
       (setq theCounter 0)
       (setvar "OSMODE" 0)
       (command "_PLINE")
       (repeat NrNodes
        (command (setq thePoint (vlax-curve-getPointAtParam MyPline (+ Param1st (* theCounter DefameSize)))))
        (setq theCounter (1+ theCounter))
       )
       (command "_Close")
     
       (command "_WIPEOUT" "_P" (entlast) "_Y")
     
       (setvar "OSMODE" OldOsmode)
      )
     )
     (princ)
    )
    Regards,
    Last edited by MSasu; 31st Jul 2010 at 07:52 pm. Reason: code updated

  8. #8
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    4,008

    Default

    Quote Originally Posted by tharwat313 View Post
    If you want to to select a polyline then divide it into a number and create a polyline to connect all the points that are
    created by the divide command, I think it's not possible .

    Because the points or nodes are do not have a XYZ when they are being made by a command divide, so the polyline or a line
    either can't find the coordinate points to connect to.
    In fact is possible to retrace the polyline after marking it with points from DIVIDE command – just need to gather the newly added entities (points) and use their coordinates as arguments for a call of PLINE command.
    Also the POINT entity is storing his X, Y and Z coordinates in DXF code 10 no matter the way used to generate it.

    Regards,

  9. #9
    Full Member pryzmm's Avatar
    Computer Details
    pryzmm's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2009
    Join Date
    Jul 2007
    Posts
    54

    Default

    msasu,,, exactly my though,, i mean,, i though everything you draw/make in autocad has values no matter what,,,, looks like we can start something from what you've just mentioned,, would you be so kind to help me start on something (lisp) with this idea,,,plsss -->> thanks

  10. #10
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    4,008

    Default

    Registered forum members do not see this ad.

    Did you tested the code in my last (#7) post? It is supposed to do what you asked for. Just load it into AutoCAD and call the new defined PLtoW command. I'm waiting for your feedback.

    Regards,

Similar Threads

  1. "Null solid created - deleted" question
    By Glen Smith in forum AutoCAD 3D Modelling & Rendering
    Replies: 2
    Last Post: 4th Dec 2009, 07:38 pm
  2. Replies: 1
    Last Post: 25th Nov 2009, 06:35 pm
  3. "Created By" Field in a Titleblock?
    By Aardvark in forum AutoCAD General
    Replies: 7
    Last Post: 10th Dec 2007, 06:41 pm
  4. Applying Command to "Last" object
    By Hardney in forum AutoCAD Drawing Management & Output
    Replies: 33
    Last Post: 24th Nov 2007, 03:19 am
  5. Getting around "null solid created ..."
    By CADIDAC in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 27th Feb 2007, 04:34 pm

Tags for this Thread

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