Results 1 to 5 of 5

Thread: Recursive roof from polylines

  1. #1
    Member
    Join Date
    2012-12
    Posts
    2

    Default Recursive roof from polylines

    Hi,
    I am new to lisp but I have experience with other programming languages.
    I am trying to create roof meshes from a number of polylines, there are thousands, so I am trying to write a simple script to get the job done.

    here is what I have so far
    Code:
    (defun roofmaker( / sset item ctr)
     
    (while
     
        (setq sset (ssget))
     
        (setq ctr 0)
    
        (repeat (sslength sset)
     
            (setq item (sset ctr))
     
            (command "_.roofconvert" item "" "n" )
     
            (setq ctr (1+ ctr))
     
        );repeat
     
    );while
     
      (princ)
     
    );defun
     
    (princ)
    Because I can't apply the roofconvert command to a set of polylines I have go through the selected set one object at a time and run that command.
    Right now I am getting an error, I am guessing it something to do with the selection list but I am not sure.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    6,836

    Default Re: Recursive roof from polylines

    Adjust this line
    Code:
    (setq item (sset ctr))
    to include the ssname function
    Code:
    (setq item (ssname sset ctr))
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,392

    Default Re: Recursive roof from polylines

    Firstly, welcome to AUGI!


    Couple of things....

    In order for your LISP to register as a Command (something you can enter at the Command line, etc.), your Defun statement's Symbol requires a "C:" prefix (not case sensitive).

    What error are you receiving specifically? That's usually helpful in offering advice.

    As I do not have any architectural software to look up for myself, you might consider this adaptation (untested):

    Code:
    (defun c:RoofMaker (/ ss i)
      (princ "\rROOFMAKER ")
      (if (setq ss (ssget "_:L" '((0 . "*POLYLINE"))))
        (repeat (setq i (sslength ss))
          (command "_.roofconvert" (ssname ss (setq i (1- i))) "" "n")
        )
        (prompt "\n** Nothing selected ** ")
      )
      (princ)
    )
    Lastly, if you already possess development experience with other languages, consider looking into your application's available API's as most (not all) support a COM, and .NET API.

    Hope this Helps (HTH)
    "Potential has a shelf life." - Margaret Atwood

  4. #4
    Member
    Join Date
    2012-12
    Posts
    2

    Default Re: Recursive roof from polylines

    Thanks, RenderMan
    that did the trick.
    definitely, extracting each object from the list was the culprit. I was not sure how lisp stores objects in a list or how it retrieves them.
    Don't really deal a lot with autocad, just needed to get this one problem solved quickly for a project I'm working on - Autocad had the roof generator I needed,
    otherwise it would have needed to write a much larger script to calculate roof slopes and 3d intersections and etc. in another environment.

  5. #5
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,392

    Default Re: Recursive roof from polylines

    Quote Originally Posted by ilya346445 View Post
    Thanks, RenderMan
    that did the trick.
    You're welcome; I'm happy to help.

    Quote Originally Posted by ilya346445 View Post
    definitely, extracting each object from the list was the culprit. I was not sure how lisp stores objects in a list or how it retrieves them.
    Don't really deal a lot with autocad, just needed to get this one problem solved quickly for a project I'm working on - Autocad had the roof generator I needed,
    otherwise it would have needed to write a much larger script to calculate roof slopes and 3d intersections and etc. in another environment.
    When dealing with LISP, major tasks often involve iteration of Selection Sets, or Lists (sometimes of Lists)... Repeat will give you the best performance when dealing with AutoLISP Lists, and for iterating Visual LISP Collection Objects (i.e., DocumentCollection, ActiveSelectionsSet, etc.), then Vlax-For is the ticket.

    Again, not sure of the languages you're familiar with, but AutoCAD supports both .NET (C#,F#,VB.NET) API, and ObjectARX (C++ for AutoCAD) API... Even though I'm progressively doing more and more .NET development (verticals such as Civil 3D are somewhat forcing that), LISP is still the quickest bang for the buck in my work.

    Let us know if we can help out with anything else - Cheers!
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. Polylines with arcs to polylines with segments
    By randyspear in forum AutoCAD General
    Replies: 1
    Last Post: 2009-04-15, 06:22 PM
  2. Replies: 7
    Last Post: 2008-02-22, 03:13 PM
  3. How to change LW PolyLines to 2D PolyLines
    By Lions60 in forum AutoLISP
    Replies: 10
    Last Post: 2007-07-13, 05:58 PM
  4. How to convert 3D Polylines to 2D Polylines
    By GreyHippo in forum AutoLISP
    Replies: 16
    Last Post: 2007-01-04, 04:32 PM

Posting Permissions

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