+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default Lisp for "dividing" objects

    Registered forum members do not see this ad.

    Hi friends...
    I think my "problem" here is pretty ez to be solved...

    Well, let´s make a "situation" here:

    - I draw a line of any size (any angle too). For eg.: 5,5 units;
    - I want it to be divide in MAX spaces of (let´s say...) 0,31 units (It means that this "max distance" of 0,31 units can be lower);
    - All that with only 1 click (to select the object) and a single "question", like: "maximum distance", where I´ll input that value of 0,31units.


    Finally...
    My object would be divided equaly...


    There´s this command DIVIDE where the PDMODE system variable is used (pdmode = 2 would be nice... I think).
    But with this DIVIDE thing, you must have an idea of how many parts the object can be divided, so that 0,31units distance doesn´t turn into a 0,01units distance...



    And that´s my "problem"...

    Any ideas to help me out?

  2. #2
    Administrator CADTutor's Avatar
    Computer Details
    CADTutor's Computer Details
    Operating System:
    Windows 7 Home Premium 64bit
    Motherboard:
    Asus P7P55D-E PRO
    CPU:
    Intel Core i7-860
    RAM:
    4GB PC3-12800 C8 Corsair Dominator
    Graphics:
    NVIDIA Quadro FX 1800 768 MB
    Primary Storage:
    Intel X25-M SSD 160GB
    Secondary Storage:
    Samsung Spinpoint 320GB
    Monitor:
    BenQ FP241W 24" Wide
    Discipline
    Education
    CADTutor's Discipline Details
    Occupation
    Senior Lecturer (Digital Design), Landscape Architect & Web Designer
    Discipline
    Education
    Using
    AutoCAD 2014
    Join Date
    Aug 2002
    Location
    Hampshire, UK
    Posts
    3,606

    Default

    OK, that sounds pretty easy but let me just clarify what you need:

    Say you have a line 12 units long and a max length value of 5.
    5 goes into 12 twice, so there must be 3 lenghts overall.
    3 into 12 goes 4 so the result of line length 12 and max length 5 is 3 lengths of 4 units.

    Do I understand you correctly?
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
    AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ

  3. #3
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default


    EXACTLY!!!!!!



    That´s right friend...

    Is it really e-z? Cuz I just figure it out in a simple way...


    Thanks for your concern...
    I´ll be waiting here for the next step..

    Thanks a lot...

  4. #4
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default

    Well...
    Here it is...
    My friend here @ my work just solved the problem, and I think it´s pretty simple...

    Anything to add would be welcome.
    And thanks everyone..

    Code:
    (vmon)
    (defun c:esp ()
     (setq espc (getreal "\nDistância máxima entre ferros: "))
     (vl-load-com) 
     (setq ob1 (car (entsel "\nSelecione Objeto: ")))
     (setq ob2 ob1)
     (setq ob1 (vlax-ename->vla-object ob1))
     (setq enn (vlax-get-property ob1 'length))
     (setq qtte (itoa (fix(+(/ enn espc)1)))) 
     (command "divide" ob2 qtte)
     (princ)
    )
    (print "Para Rodar o Programa Digite esp")
    ps.: the language there is portuguese, just in case anyone asks... lol
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  5. #5
    JimWebster
    Guest

    Default

    After Selecione Objeto: I am getting ; error: ActiveX Server returned the error: unknown name: LENGTH

    I have Portugese-English dictionary handy. Would FERROS be BOLTS, POINTS. or what in English?

  6. #6
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default

    Quote Originally Posted by JimWebster
    After Selecione Objeto: I am getting ; error: ActiveX Server returned the error: unknown name: LENGTH

    I have Portugese-English dictionary handy. Would FERROS be BOLTS, POINTS. or what in English?
    Hi Jim, now it´s close to what I wanted. I also translated the portuguese parts so you can understand it better, just take a look:

    Code:
    (vmon)
    (defun c:DIVID ()
     (setvar "pdmode" 2)
     (setq espc (getreal "\Max distance between points: "))
     (vl-load-com) 
     (setq ob1 (car (entsel "\nSelect Object: ")))
     (setq ob2 ob1)
     (setq ob1 (vlax-ename->vla-object ob1))
     (setq enn (vlax-get-property ob1 'length))
     (setq qtte (itoa (fix(+(/ enn espc)1)))) 
     (command "divide" ob2 qtte)
     (princ)
    )
    (print "To use this program type DIVID")

    It now has the (setvar "pdmode" 2) line. It is the same as typing DDPTYPE and selecting the third symbol.

    The "problem" is that we can only use this lisp with LINES. We are working here so it can be used in splines, plines, arcs, circles, etc....


    And FERRO means IRON, but we actually mean STEEL, which is AÇO in portuguese.
    That´s how the "aço" "divides" inside our concrete panels.



    Thanks!
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  7. #7
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    To get lengths of all (?) curve types, you need to use;

    vlax-curve-getEndParam and
    vlax-curve-getDistAtParam

    where the "parameter" for the second function is determined by the first function.

    HTH!

  8. #8
    JimWebster
    Guest

    Default

    Gotcha fade2blackened. I'm looking forward to the finished product now.
    I tested the English version and it works great.

    I spent about 3 years working in Buenos Aires, Argentina. At which point I learned a little Spanish.
    My company also has an office in Sao Paulo (Lockwood Greene), so I have gotten to meet a
    few people from Brazil. All of the above sparked my interest concerning the Portugese language.
    Therefore, I purchased a Portugese-English dictionary for a low price in Buenos Aires.
    I'm assuming by your photo that Brazil has mostly concrete construction, the same as Argentina.
    Correct? Being for the United States that is odd, since most construction here is wood or steel.

  9. #9
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default

    Quote Originally Posted by JimWebster
    Gotcha fade2blackened. I'm looking forward to the finished product now.
    I tested the English version and it works great.

    I spent about 3 years working in Buenos Aires, Argentina. At which point I learned a little Spanish.
    My company also has an office in Sao Paulo (Lockwood Greene), so I have gotten to meet a
    few people from Brazil. All of the above sparked my interest concerning the Portugese language.
    Therefore, I purchased a Portugese-English dictionary for a low price in Buenos Aires.
    I'm assuming by your photo that Brazil has mostly concrete construction, the same as Argentina.
    Correct? Being for the United States that is odd, since most construction here is wood or steel.

    Thanks Jim...
    I´ll soon post the "final version". At my works it comes really handy... I hope it helps you somehow too.

    That photo is of a building (INAJAROBA, in São Paulo) I was working on (panels) some months ago and I can say it´s a "luxury building" to live in... Too much for me...

    Now I´m just a lil curious to know what you do... if I might say "what are you?" (lol).

    See you soon friend...
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  10. #10
    JimWebster
    Guest

    Default

    Registered forum members do not see this ad.

    I'm a Structural Steel Detailer. With the most of my experience in the prefab metal building trade.
    I studied to be an Architect and that was my ambition. But due to a high unemployment rate in the
    USA at the time that I finished school, and the fact that I had a family to support, I started doing
    structural steel detailing work. And now over 20 years later, here I still am. For the past 5 years
    I have been working for an international engineering and design firm.

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