See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Perpendicular 2D snap to line

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

    Default Perpendicular 2D snap to line

    AutoCAD snaps to Perpendicular in 3D. Need to snap as if line endpoints had the same elevation. I don't want elevation to have any effect on Perpendicular while OSNAPZ is set to 1. Currently I draw a lwpolyline on top to snap to and delete it afterwards.

    Has anyone got any code or ideas? All I could think of would be to do the same with lisp deleting the added line afterwards. Seems like there should be a cleaner process.

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

    Default Re: Perpendicular 2D snap to line

    Couldn't you just modify the resultant Curve Object's Elevation Property after the fact?
    "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

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

    Default Re: Perpendicular 2D snap to line

    Quote Originally Posted by BlackBox View Post
    Couldn't you just modify the resultant Curve Object's Elevation Property after the fact?
    I guess, but how does that help me get ┴ instead of <? Looking for 2D Perpendicular osnap, one that would be Perpendicular if the lines were flattened. Having the Elevation the same as where the lines meet makes sense, but the only thing I'm looking for right now is 2D (or Plan view) Perpendicular osnap. Just can't figure out how to get started on the code.

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

    Default Re: Perpendicular 2D snap to line

    Backing up for a moment... I may be slow, bare with me... You're wanting to snap perpendicular to a 3D entity when OSNAPZ=1, and have the resultant Curve (i.e., Line, Polyline, etc.) be 2D, correct?
    Last edited by BlackBox; 2013-05-07 at 01:35 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

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

    Default Re: Perpendicular 2D snap to line

    Now I understand... My PERP snap point ends up being off in space, rather than 'near' my actual snap point specification... Lemme see what I can slap together.
    "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

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

    Default Re: Perpendicular 2D snap to line

    Like you've already pointed out, adding a [2D] LWPolyline over top of the [3D] Polyline is the only way I am able to achieve the desire '2d' snap as well.

    Here's a quick automation, that will prevent you from having to manually draw the [2D] LWPolyline... Select the [3D] Polyline, specify your start point, and then the PERP point (of the [3D] Polyline):

    Code:
    (vl-load-com)
    
    (defun c:Perp2d (/ *error* ss oSource oPline)
      (prompt "\nSelect polyline to snap Perp2d: ")
    
    
      (defun *error* (msg)
        (if oSource (vla-highlight oSource :vlax-false))
        (if oPline (vla-delete oPline))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
    
      (if (and (setq ss (ssget ":S:E" '((0 . "POLYLINE"))))
               (setq oSource (vlax-ename->vla-object
                              (ssname ss 0)
                            )
               )
          )
        (progn
          (vla-highlight oSource :vlax-true)
          (vla-put-layer
            (setq oPline (vla-addpolyline
                         (vla-get-modelspace
                           (vla-get-activedocument (vlax-get-acad-object))
                         )
                         (vla-get-coordinates oSource)
                       )
                  )
            (vla-get-layer oSource)
          )
          (command "._pline" pause "_perp" pause "")
        )
      )
      (*error* nil)
    )
    "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
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Perpendicular 2D snap to line

    Quote Originally Posted by BlackBox View Post
    Like you've already pointed out, adding a [2D] LWPolyline over top of the [3D] Polyline is the only way I am able to achieve the desire '2d' snap as well.

    Here's a quick automation, that will prevent you from having to manually draw the [2D] LWPolyline... Select the [3D] Polyline, specify your start point, and then the PERP point (of the [3D] Polyline):
    Works great for 3D polylines which is nice. I can add support for lines myself.
    Thanks,

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

    Default Re: Perpendicular 2D snap to line

    Quote Originally Posted by Tom Beauford View Post
    Works great for 3D polylines which is nice. I can add support for lines myself.
    Thanks,
    Happy to help, Tom... I'd be interested to see what your adaptation looks like, when done.



    Here's one that works on *LINE Objects, and accounts for ModelSpace, PaperSpace, and PViewport Active:

    Code:
    (defun c:Perp2d (/ *error* ss oSource oPline lst)
      (prompt "\nSelect polyline to snap Perp2d: ")
    
      (defun *error* (msg)
        (if oSource
          (vla-highlight oSource :vlax-false)
        )
        (if oPline
          (vla-delete oPline)
        )
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if (and (setq ss (ssget ":S:E" '((0 . "*LINE"))))
               (setq oSource (vlax-ename->vla-object
                               (ssname ss 0)
                             )
               )
          )
        (progn
          (vla-highlight oSource :vlax-true)
          (vla-put-layer
            (setq oPline
                   (vla-addpolyline
                     (vlax-get
                       (vla-get-activedocument (vlax-get-acad-object))
                       (if (= 1 (getvar 'tilemode))
                         'modelspace
                         (if (= 1 (getvar 'cvport))
                           'paperspace
                           'modelspace
                         )
                       )
                     )
                     (if (= "AcDbLine" (vla-get-objectname oSource))
                       (progn
                         (setq lst
                                (list (vlax-curve-getstartpoint oSource)
                                      (vlax-curve-getendpoint oSource)
                                )
                         )
                         (vlax-make-variant
                           (vlax-safearray-fill
                             (vlax-make-safearray
                               vlax-vbDouble
                               (cons 0 (1- (length (apply 'append lst))))
                             )
                             (apply 'append lst)
                           )
                         )
                       )
                       (vla-get-coordinates oSource)
                     )
                   )
            )
            (vla-get-layer oSource)
          )
          (command "._pline" pause "_perp" pause "")
        )
      )
      (*error* nil)
    )
    "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

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

    Default Re: Perpendicular 2D snap to line

    Quote Originally Posted by BlackBox View Post
    Happy to help, Tom... I'd be interested to see what your adaptation looks like, when done.
    Only works for perpendicular to a line for now, but it doesn't matter what command is prompting for the point.
    Code:
     ; (load "PerpEnt.lsp") (PerpEnt) ;
    (defun PerpEnt (/ *error* pt ent el pt1 pt2 el0 el2)
      (load "flattensup.lsp")
    
      (defun *error* (msg)
        (entmod el)
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (setq ent (entsel)
          pt (cadr ent)
          ent (car ent)
          el (entget ent)
          pt1 (assoc 10 el)
          pt1 (cdr (reverse pt1))
          pt1 (append (list(getvar 'ELEVATION)) pt1)
          pt1 (reverse pt1)
          pt2 (assoc 11 el)
          pt2 (cdr (reverse pt2))
          pt2 (append (list(getvar 'ELEVATION)) pt2)
          pt2 (reverse pt2)
          el0 (subst pt1 (assoc 10 el) el)
          el0 (subst pt2 (assoc 11 el0) el0)
      )
        (entmod el0)
        (vl-cmdf "PER" pt)
        (entmod el)
      (while (= 1 (logand 1 (getvar 'cmdactive)))
        (vl-cmdf PAUSE)
      );while
      (princ)
    )

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

    Default Re: Perpendicular 2D snap to line

    Still only works for perpendicular to a line for now, but now the Elevation is where the lines meet. Tested with the line and poly commands. Had to use cal to calculate the intersection of a line & a plane. Can that be done with lisp?
    Code:
     ; (load "PerpEnt.lsp") (PerpEnt) ;
    ; ^P(or PerpEnt (load "PerpEnt.lsp"));(PerpEnt)
     (defun PerpEnt (/ *error* pt ent el pt1 pt2 pt3 pt4 pt5 pt6 el0 ent2 el2 cmd)
    ;(defun PerpEnt (/ *error* pt ent el el0 el2)
      (load "flattensup.lsp")
      (or cal (arxload "geomcal"))
    
      (defun *error* (msg)
        (entmod el)
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (setq ent (entsel)
          pt (cadr ent)
          ent (car ent)
          el (entget ent)
          pt1 (assoc 10 el)
          pt3 (cdr (reverse pt1))
          pt3 (append (list(getvar 'ELEVATION)) pt3)
          pt3 (reverse pt3)
          pt2 (assoc 11 el)
          pt4 (cdr (reverse pt2))
          pt4 (append (list(getvar 'ELEVATION)) pt4)
          pt4 (reverse pt4)
          pt1 (cdr pt1)
          pt2 (cdr pt2)
          el0 (subst pt3 (assoc 10 el) el)
          el0 (subst pt4 (assoc 11 el0) el0)
          pt3 (cdr pt3)
          pt4 (cdr pt4)
      )
      (entmod el0)
      (vl-cmdf "PER" pt)
      (setq ent2 (entlast)
          el2 (entget ent2)
      )
      (entmod el)
      (if (= "LINE" (cdr(assoc 0 el2)))
          (progn
    	  (setq pt3 (cdr(assoc 10 el2))
    	      pt4 (cdr(assoc 11 el2))
    	      pt5 (reverse(append (list 1111.1)(cdr(reverse pt4))))
    	      cmd (getvar 'cmdnames)
    	  )
    	  (setq pt6 (c:cal "ilp(pt1,pt2,pt3,pt4,pt5)")
    	      pt6 (append (list 11) pt6)
    	      el2 (subst pt6 (assoc 11 el2) el2)
    	  )
    	  (entmod el2)
    	  (command cmd)
          )
      )
      (while (= 1 (logand 1 (getvar 'cmdactive))) ; PAUSE while command is active
        (vl-cmdf PAUSE)
      );while
      (princ)
    )

Page 1 of 2 12 LastLast

Similar Threads

  1. Multileader snap perpendicular to arc
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-06-12, 06:00 PM
  2. Perpendicular & nearest won't snap to arc
    By gadjet in forum AutoCAD General
    Replies: 4
    Last Post: 2007-05-08, 07:13 AM
  3. Replies: 5
    Last Post: 2006-11-09, 07:19 PM
  4. Perpendicular Object Snap
    By SHEILA in forum ACA General
    Replies: 6
    Last Post: 2004-10-06, 06:41 PM
  5. Deferred Perpendicular Snap
    By rpetrie in forum AutoCAD General
    Replies: 3
    Last Post: 2004-10-04, 07:13 AM

Posting Permissions

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