Author Topic: "Continue" an arc from a line or arc that is NOT the last entity  (Read 2529 times)

0 Members and 1 Guest are viewing this topic.

rhgrafix

  • Mosquito
  • Posts: 3
I can't find a way to draw an arc off the end of a line or arc that is NOT the last entity and have it act as though it was continuing in the normal way, like it does when continuing off the end of the last entity drawn. As in, have it behave like an arc coming off the last entity but select a random different arc in the drawing. I always have to trace the arc or line that I want to continue off of, then use arc continue as normal. Tangent does not work because then you have to pick Center or End and then you're locked into an arc that is not behaving like a continuing arc. I hope this makes sense.
I have a feeling it will be something like a small .lsp or .vlx program that moves the selected entity to the last item in the db dictionary, then I'd still have a 50/50 chance that it would be the correct end of the line or arc that I want.
I know someone here knows how to do this!
Thanks much,
R.L. Hamm

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #1 on: July 16, 2018, 05:53:58 AM »
I have this 'lying around'.

ribarm

  • Gator
  • Posts: 2520
  • Marko Ribar, architect
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #2 on: July 16, 2018, 07:39:13 AM »
No roy, maybe it works in BricsCAD, but in AutoCAD it doesn't...
I just tested your lisp...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 2520
  • Marko Ribar, architect
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #3 on: July 16, 2018, 08:06:16 AM »
Here is AutoCAD implementation... Of course thanks to Roy...

Code: [Select]
;;; Created for: http://www.bricsys.com/common/support/forumthread.jsp?id=26089
;;; Author:      Roy Klein Gebbinck (www.b-k-g.nl)
;;; Modified:    Marko Ribar (AutoCAD implementation)

(defun c:ArcFollow ( / cmde deriv dist lst obj pt el)

  (vl-load-com)

  (if
    (and
      (setq lst (entsel))
      (setq obj (vlax-ename->vla-object (car lst)))
      (or
        (vl-position
          (vla-get-objectname obj)
          '("AcDb2dPolyline"  "AcDbArc" "AcDbCircle" "AcDbEllipse" "AcDbLine" "AcDbPolyline" "AcDbSpline")
        )
        (prompt "\nError: invalid object \n")
      )
      (or
        (equal (vlax-get obj 'normal) (trans '(0.0 0.0 1.0) 1 0 T) 1e-8)
        (prompt "\nError: object not co-planar with current UCS \n")
      )
    )
    (progn
      (setq dist (vlax-curve-getdistatpoint obj (vlax-curve-getclosestpointto obj (trans (cadr lst) 1 0))))
      (if (< dist (- (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) dist))
        (progn ; Closer to the start point.
          (setq pt (vlax-curve-getstartpoint obj))
          (setq deriv (mapcar '- (vlax-curve-getfirstderiv obj (vlax-curve-getstartparam obj))))
        )
        (progn
          (setq pt (vlax-curve-getendpoint obj))
          (setq deriv (vlax-curve-getfirstderiv obj (vlax-curve-getendparam obj)))
        )
      )
      (setq cmde (getvar 'cmdecho))
      (setvar 'cmdecho 0)
      (setq el (entlast))
      (vl-cmdf "_.LINE" "_non" (trans pt 0 1) "_non" (trans (mapcar '- pt deriv) 0 1) "_non" (trans pt 0 1) "")
      (while (setq el (entnext el))
        (entdel el)
      )
      (vl-cmdf
        "_.arc"
        ""
      )
      (while (> (getvar 'cmdactive) 0)
        (vl-cmdf "\\")
      )
      (setvar 'cmdecho cmde)
    )
  )
  (princ)
)
« Last Edit: July 16, 2018, 08:39:25 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #4 on: July 16, 2018, 10:07:36 AM »
@ribarm:
Thanks.
So using the Direction option, which is available in AutoCAD as well, is not feasible in that program?

ribarm

  • Gator
  • Posts: 2520
  • Marko Ribar, architect
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #5 on: July 16, 2018, 11:11:47 AM »
@ribarm:
Thanks.
So using the Direction option, which is available in AutoCAD as well, is not feasible in that program?

There is no Direction option in AutoCAD, you only have sysvars 'LASTPOINT which is not read-only and 'LASTANGLE which is read-only...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #6 on: July 16, 2018, 12:23:30 PM »
@ribarm:
You have misunderstood my previous post. If you step back to my code you will see that it uses the Direction option of the Arc command. According to the docs this option is also available in AutoCAD. What are your reasons for changing this part of the code?

MSTG007

  • Gator
  • Posts: 2507
  • I can't remeber what I already asked! I need help!
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #7 on: July 16, 2018, 01:09:02 PM »
I tried Roy's code. This is what is on the command line:
Code: [Select]
Command: arcfollow
Select object:
2D point or option keyword required.
; error: Function cancelled
Specify second point of arc or [Center/End]:
Specify end point of arc:
Command: *Cancel*
Civil3D 2020

rhgrafix

  • Mosquito
  • Posts: 3
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #8 on: July 16, 2018, 11:26:21 PM »
YES YES YES! :2funny: That works perfectly! It even allows me to choose which end to tangent from,
thank you so much, Roy you are a genius!
Challenge #2
 I have been curious if this would be easily doable (for someone who is way better at code than I):
Select a shared grip where 2 arcs meet, as in the middle of an S shape, the goal being a perfect tangent to tangent S (arcs don't need to be equal radii), and dynamically pull this point around to a new place, leaving a good joint of 2 arcs.  This is something that was built into Flash editor, that I used years ago, I'm not sure if Inkscape can do it but I don't like the UI of that app. I prefer Autocad to draw my custom lettering and artwork because I know the program and I do a lot of 3D modelling.
Thanks!
R.L. Hamm

rkmcswain

  • Swamp Rat
  • Posts: 963
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #9 on: July 17, 2018, 08:20:31 AM »
@ribarm:
You have misunderstood my previous post. If you step back to my code you will see that it uses the Direction option of the Arc command. According to the docs this option is also available in AutoCAD. What are your reasons for changing this part of the code?

The Direction Option of the ARC command in AutoCAD is only available if and after you use the CENTER point as a start option you specify the start and end points.
It's not the same as BricsCAD.
« Last Edit: July 17, 2018, 08:56:36 AM by rkmcswain »

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #10 on: July 17, 2018, 09:58:34 AM »
The Direction Option of the ARC command in AutoCAD ... It's not the same as BricsCAD.
Thanks for clarifying.

I would change this in ribarm's code:
Code: [Select]
(while (setq el (entnext el))
  (entdel el)
)
To this:
Code: [Select]
(if (not (equal el (entlast)))
  (entdel (entlast))
)
Reason: entnext will also catch sub-entities.

ribarm

  • Gator
  • Posts: 2520
  • Marko Ribar, architect
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #11 on: July 17, 2018, 11:05:14 AM »
The Direction Option of the ARC command in AutoCAD ... It's not the same as BricsCAD.
Thanks for clarifying.

I would change this in ribarm's code:
Code: [Select]
(while (setq el (entnext el))
  (entdel el)
)
To this:
Code: [Select]
(if (not (equal el (entlast)))
  (entdel (entlast))
)
Reason: entnext will also catch sub-entities.

No Roy, there are only 2 entities - lines that are created... No catching of sub entities as they are lines... And as there are 2 of them the part of the code that I posted should remain...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #12 on: July 17, 2018, 04:17:16 PM »
@ribarm:
The fact that you draw two lines escaped my notice. I think one will do.
But the issue I referred in my previous post does exist. Just insert an attributed block as the last entity and then test your code. In BricsCAD V18 the attributes of the insert are deleted and an error is reported.

Improved code:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:ArcFollow ( / cmde deriv dist lst obj pt el)
  2.   (if
  3.     (and
  4.       (setq lst (entsel))
  5.       (setq obj (vlax-ename->vla-object (car lst)))
  6.       (or
  7.         (vl-position
  8.           (vla-get-objectname obj)
  9.           '("AcDb2dPolyline"  "AcDbArc" "AcDbCircle" "AcDbEllipse" "AcDbLine" "AcDbPolyline" "AcDbSpline")
  10.         )
  11.         (prompt "\nError: invalid object \n")
  12.       )
  13.       (or
  14.         (equal (vlax-get obj 'normal) (trans '(0.0 0.0 1.0) 1 0 T) 1e-8)
  15.         (prompt "\nError: object not co-planar with current UCS \n")
  16.       )
  17.       (or
  18.         (zerop (logand (cdr (assoc 70 (tblsearch "layer" (getvar 'clayer)))) 4))
  19.         (prompt "\nError: current layer is locked \n")
  20.       )
  21.     )
  22.     (progn
  23.       (setq dist (vlax-curve-getdistatpoint obj (vlax-curve-getclosestpointto obj (trans (cadr lst) 1 0))))
  24.       (if (< dist (- (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) dist))
  25.         (progn ; Closer to the start point.
  26.           (setq pt (vlax-curve-getstartpoint obj))
  27.           (setq deriv (mapcar '- (vlax-curve-getfirstderiv obj (vlax-curve-getstartparam obj))))
  28.         )
  29.         (progn
  30.           (setq pt (vlax-curve-getendpoint obj))
  31.           (setq deriv (vlax-curve-getfirstderiv obj (vlax-curve-getendparam obj)))
  32.         )
  33.       )
  34.       (setq cmde (getvar 'cmdecho))
  35.       (setvar 'cmdecho 0)
  36.       (setq el (entlast))
  37.       (vl-cmdf "_.LINE" "_non" (trans (mapcar '- pt deriv) 0 1) "_non" (trans pt 0 1) "")
  38.       (if (not (equal el (entlast)))
  39.         (progn
  40.           (entdel (entlast))
  41.           (vl-cmdf
  42.             "_.arc"
  43.             ""
  44.           )
  45.           (while (> (getvar 'cmdactive) 0)
  46.             (vl-cmdf "\\")
  47.           )
  48.         )
  49.         (princ "\nError: could not create temporary line \n")
  50.       )
  51.       (setvar 'cmdecho cmde)
  52.     )
  53.   )
  54.   (princ)
  55. )

ribarm

  • Gator
  • Posts: 2520
  • Marko Ribar, architect
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #13 on: July 18, 2018, 03:03:03 AM »
@Roy

I've tested my version (while (setq el (entnext el)) (entdel el)) on a DWG where last entity was attributed block, and it worked fine - no attributes were deleted... But I appreciate your input - it is more professionally written, so I decided to use your revision... Thanks God that AutoCAD is immune to this snippet, I don't know how many times I used it, although I am pretty sure I tested it and before on that situation (block with attributes as last entity)... Thank you Roy...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1876
  • BricsCAD 18
Re: "Continue" an arc from a line or arc that is NOT the last entity
« Reply #14 on: July 26, 2018, 05:26:18 AM »
@ribarm & FYI:
I have reported this issue to Bricsys. And, indeed, entdel was not compatible with AutoCAD here. This will be fixed in the next BricsCAD release.