Results 1 to 7 of 7

Thread: could this be written in autolisp?

  1. #1
    Login to Give a bone
    0

    Default could this be written in autolisp?

    I want a 3dpoly to automatically draw from point to point. Instead of a survey feature drawing from point number order or it drawing in the order of entry it needs to draw to the next closest cogo point. Is this possible using a lisp?

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    Seems like a line would be all you would need to connect between two 3d points. Nearest point in 2d or 3d? A 3dpoly can only do straight segments while a feature line can carry elevations around a curve. What exactly are you trying to accomplish?

  3. #3
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    It is possible, I've done a some stuff using cogo points, but its not something I can bang out quick like. Also the way I'm thinking of doing it would bog down with a large number of points in the drawing if you're not entering points through a point number or picking individually, it would have to iterate through all the points, exclude any already used and find the next closest one.

    then you can use
    Code:
    (vlax-get <point converted to vla-object here> 'easting)
    (vlax-get <point converted to vla-object here> 'northing)
    (vlax-get <point converted to vla-object here> 'elevation)
    to get the x,y,z of each point

    then it's just a matter of entmaking a 3dpoly with those points

    Yeah I'm sure its possible but I'm too rookie to know an easy way off the top of my head, and too busy to work it up the long way right now. If no one else comes up with a better solution I'll see what I can do later.

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    Quote Originally Posted by james.k.barnett376800 View Post
    I want a 3dpoly to automatically draw from point to point.
    Quote Originally Posted by Tom Beauford View Post
    Seems like a line would be all you would need to connect between two 3d points.
    If I'm not using a feature line, then I use lines - mainly because 3D polylines do not show linetypes.
    Just something to consider.
    R.K. McSwain | CAD Panacea |

  5. #5
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    eh, heres some sloppy code, but appears to work with what limited testing i've put it to could use a lot a cleaning some error trapping spit and/or polish but here's the bones

    Code:
    (defun c:poly-closest ( / tmppt1 tmppt2 tmpen pts-raw-list cnt pts-raw draw-list en )
    (vl-load-com)
    (prompt "Select Starting Point: ")
    (while (not (setq en (vlax-ename->vla-object (ssname (ssget "_+.:E:S" '((0 . "AECC_COGO_POINT"))) 0)) )))
    (setq draw-list (list en))
    (setq pts-raw (ssget "_A" '((0 . "AECC_COGO_POINT"))))
    (setq cnt 1)
    (setq pts-raw-list (list (vlax-ename->vla-object (ssname pts-raw 0))))
    (repeat (- (sslength pts-raw) 1)
    (setq pts-raw-list (append pts-raw-list (list (vlax-ename->vla-object (ssname pts-raw cnt)))))
    (setq cnt (+ 1 cnt))
    );repeat
    (setq pts-raw-list (remove-member pts-raw-list en))
    (setq cnt 0)
    (while (not (= pts-raw-list '() ))
    
    (repeat (length pts-raw-list)
    (setq tmppt1 (list (vlax-get en 'easting) (vlax-get en 'northing) (vlax-get en 'elevation) ))
    (setq tmppt2 (list (vlax-get (nth cnt pts-raw-list) 'easting) (vlax-get (nth cnt pts-raw-list) 'northing) (vlax-get (nth cnt pts-raw-list) 'elevation) ))
    (if (= tmpen nil)
    (setq tmpen (nth cnt pts-raw-list))
    (progn
    (if (< (distance tmppt1 tmppt2) tmpdist)
    (progn
    (setq tmpen (nth cnt pts-raw-list) tmpdist (distance tmppt1 tmppt2))
    );progn
    );if
    );progn
    );if
    (setq cnt (+ 1 cnt))
    );repeat
    
    (setq en tmpen)
    (setq tmpen nil)
    (setq cnt 0)
    (setq draw-list (append draw-list (list en)))
    (setq pts-raw-list (remove-member pts-raw-list en))
    
    );while
    
    (setq draw-list (mapcar '(lambda (a) (list (vlax-get a 'easting) (vlax-get a 'northing) (vlax-get a 'elevation))) draw-list))
    
    (setq cnt 0)
    
    (entmake (list (cons 0 "POLYLINE")
    	   (cons 70 8)
    	   (cons 66 1)
    	   ))
    (repeat (length draw-list)
      (setq tmppt1 (nth cnt draw-list))
    (entmake (list (cons 0 "VERTEX")
    (cons 70 32)
    (cons 10 tmppt1)))
    (setq cnt (+ 1 cnt))
    );repeat
    (entmake (list (cons 0 "SEQEND")))
    (princ)
    );defun
    
    (defun remove-member ( lst mbr / part1 part2 )
    (setq part1 (reverse (cdr (member mbr (reverse lst)))))
    (setq part2 (cdr (member mbr lst)))
    (append part1 part2)
    )

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    To speed up the iteration of COGO points you'd want to first store them to a list of grouped pairs, sorted by distance, perhaps coordinate/object, in order to reduce the number of times you query the objects. Then, if in .NET, can use (P?)LINQ, to expedite the entire process further... Tony posted an example of iterating hundreds of thousands (if not millions?) of points (not COGO), that may be informative.

    Cheers
    Last edited by BlackBox; 2014-08-29 at 03:07 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Login to Give a bone
    0

    Default Re: could this be written in autolisp?

    Thanks for the responses everyone. I'm away from my computer quite a bit so my replies are sporadic.

    Tom: A 2d distance is close enough and I don't see why straight segments would be a problem. What I am trying to do is get the cover of a pipeline. I have shots on the top of pipe and shots on the existing surface. The existing surface points are in a line following the pipe, so I draw a 3dpoly down the line of ng (natural ground) shots and then offset it 10-15 feet. This allows me to make a surface that I can easily use to get the cover of the pipeline. If I have a 10 mile long pipeline with a shot every 40 feet it takes a while to do that by hand. That is why I thought a lisp would work good. I don't know if it matters, but we always have a proposed alignment of the pipeline also.

    rkmcswain: lines are fine, I will just join them after so I can offset it both directions to cover my entire area.

    ccalder: I am about to get on a plane, but hopefully I can look at this code Monday morning. It looks like this is way over my head, but maybe I can break it down in smaller parts first. I really appreciate you posting this though.

    blackbox: I don't know much about lsp an less about .net, but I will give it a look. Thanks for the info.

Similar Threads

  1. 2014: Revit to Rhino - Can a Plug-in be written?
    By KoryCox in forum Revit Architecture - General
    Replies: 6
    Last Post: 2014-06-30, 02:23 PM
  2. What is your favorite app written with the API?
    By bowlingbrad in forum Revit - API
    Replies: 2
    Last Post: 2012-05-30, 02:08 AM
  3. PBLM w/AutoLISP "BFIND" written by Lee Mac
    By rzuk383263 in forum AutoLISP
    Replies: 4
    Last Post: 2011-08-12, 03:54 PM
  4. Extensions4revit, is this written in the API?
    By r.howarth in forum Revit - API
    Replies: 2
    Last Post: 2008-05-20, 02:04 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
  •