Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/26/2022 in all areas

  1. Thanks again everyone I think I’ve got it working now… Exceed called it! This is for a larger routine and I’m needing the offset lines just for coordinates. The coordinates I need are at the ends of the offset lines (circles in yellow for illustration purposes). Everything created are just guidelines and will be deleted at the end of my final routine. Here is what I have working so far. Now will see if I can implement it into my larger routine. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Create rectangle. Create midpoint on shortest side. Draw midpoint line. Offset line by 10. Add circles ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:zzz (/ mylength mywidth pt1 pt2 pt3 pt4 pt5 pt6 offsetline1 offsetline2 offsetline1startpt offsetline1endpt offsetline2startpt offsetline2endpt) (vl-load-com) (setq oldecho (getvar 'cmdecho)) (setvar 'cmdecho 0) (setq pt1 (getpoint "\nPick the first point") pt3 (getcorner "\Pick the next corner" pt1) ) (vl-cmdf "_.rectang" pt1 pt3) (setq pt2 (vlax-curve-getPointAtParam (entlast) 1) pt4 (vlax-curve-getPointAtParam (entlast) 3) ) ;Get length and width of rectangle (setq mylength (distance pt1 pt2)); length (setq mywidth (distance pt1 pt4)) ; width ;Find out which is the shorter side of the rectangle and then draw a line between the midpoints (if (> mywidth mylength); if mywidth is greather than mylength ( if true then...) (progn (setq pt5 (list (/ (+ (car pt1) (car pt4)) 2) (/ (+ (cadr pt1) (cadr pt4)) 2))) (setq pt6 (list (/ (+ (car pt2) (car pt3)) 2) (/ (+ (cadr pt2) (cadr pt3)) 2))) (entmake (list '(0 . "LINE") (cons 10 pt5) (cons 11 pt6) ) ) ;;; Create +10 Offset of Midpoint line. Draw yellow circles at each end of offset line (setq ent (vlax-ename->vla-object (entlast))) (setq offsetline1 (vla-offset ent 10)) (setq offsetline1startpt (vlax-curve-GetStartPoint (vlax-ename->vla-object (entlast)))) (setq offsetline1endpt (vlax-curve-GetEndPoint (vlax-ename->vla-object (entlast)))) ;Draw a circle at the end of the offset lines with diameter of 2 (entmake (list '(0 . "CIRCLE") (cons 10 offsetline1startpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) (entmake (list '(0 . "CIRCLE") (cons 10 offsetline1endpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) ;;; Create -10 Offset of Midpoint line. Draw yellow circles at each end of offset line (setq offsetline2 (vla-offset ent -10)) (setq offsetline2startpt (vlax-curve-GetStartPoint (entlast))) (setq offsetline2endpt (vlax-curve-GetEndPoint (entlast))) ;Draw a circle at the end of the offset lines with diameter of 2 (entmake (list '(0 . "CIRCLE") (cons 10 offsetline2startpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) (entmake (list '(0 . "CIRCLE") (cons 10 offsetline2endpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) );End Progn ; If its not true then... (progn (setq pt5 (list (/ (+ (car pt1) (car pt2)) 2) (/ (+ (cadr pt1) (cadr pt2)) 2))) (setq pt6 (list (/ (+ (car pt3) (car pt4)) 2) (/ (+ (cadr pt3) (cadr pt4)) 2))) (entmake (list '(0 . "LINE") (cons 10 pt5) (cons 11 pt6) ) ) ;;; Create +10 Offset of Midpoint line. Draw yellow circles at each end of offset line (setq ent (vlax-ename->vla-object (entlast))) (setq offsetline1 (vla-offset ent 10)) (setq offsetline1startpt (vlax-curve-GetStartPoint (vlax-ename->vla-object (entlast)))) (setq offsetline1endpt (vlax-curve-GetEndPoint (vlax-ename->vla-object (entlast)))) ;Draw a circle at the end of the offset lines with diameter of 2 (entmake (list '(0 . "CIRCLE") (cons 10 offsetline1startpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) (entmake (list '(0 . "CIRCLE") (cons 10 offsetline1endpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) ;;; Create -10 Offset of Midpoint line. Draw yellow circles at each end of offset line (setq offsetline2 (vla-offset ent -10)) (setq offsetline2startpt (vlax-curve-GetStartPoint (entlast))) (setq offsetline2endpt (vlax-curve-GetEndPoint (entlast))) ;Draw a circle at the end of the offset lines with diameter of 2 (entmake (list '(0 . "CIRCLE") (cons 10 offsetline2startpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) (entmake (list '(0 . "CIRCLE") (cons 10 offsetline2endpt) (cons 40 4); size 2 diameter ;;color Yellow '(62 . 2) ) ) ) ;End Progn ) ;_ if (setvar 'cmdecho oldecho) ); End Program End result: I appreciate everyone’s input!
    1 point
  2. This uses the line comand so one less click if your drawing multiple connected lines. ;;----------------------------------------------------------------------;; ;; Offset line(s) by 10 on both sides (defun C:OBLine (/ ss LastEnt en ent) (setq ss (ssadd)) (setq LastEnt (entlast)) (command "line" (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause))) (if (setq en (entnext LastEnt)) (while en (ssadd en ss) (setq en (entnext en)) ) ) (if (> (sslength ss) 0) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq ent (vlax-ename->vla-object ent)) (vla-offset ent 10) (vla-offset ent -10) ) ) (princ) )
    1 point
  3. FYI (setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'BasePoint)))) (setq pt1 (vlax-get lno 'BasePoint))
    1 point
  4. oh that's my spam. I forgot that I had written this haha, but it looked familiar. Perhaps he wants to use this as part of another Lisp. so he wants that coordinates. for example, make the MLINE command by autolisp
    1 point
  5. mhupp that was in the code so left it there if not needed delete it. Just removed rem to make sure was working.
    1 point
  6. (vl-load-com) (defun c:oset ( / di ln nm p1 lno lntype pt1 pt2 polycoord polycoordlen ) (if (and (setq ln (ssget "_+.:E:S" '((0 . "*LINE")))) (setq di (getreal "\nSpecify Offset Distance: ")) ) (progn (setq lno (vlax-ename->vla-object (ssname ln 0))) (setq lntype (vlax-get-property lno 'EntityName)) (cond ((= lntype "AcDbLine") (setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'StartPoint)))) (setq pt2 (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'EndPoint)))) ) ((= lntype "AcDbXline") (setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'BasePoint)))) (setq pt2 (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'SecondPoint)))) ) ((= lntype "AcDbPolyline") (setq polycoord (vlax-safearray->list (vlax-variant-value (vlax-get-property lno 'coordinates)))) (setq polycoordlen (length polycoord)) (setq pt1 (list (car polycoord) (cadr polycoord) 0.0)) (setq pt2 (list (nth (- polycoordlen 2) polycoord) (last polycoord) 0.0)) ) ) (setq nm (mapcar '- pt1 pt2)) (setq p1 (trans (cdr pt1) 0 nm)) (entmake (list (cons 0 "XLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbXline") (cons 8 "Construction Line") (cons 10 (trans (list (+ (car p1) di) (cadr p1) (caddr p1)) nm 0)) (cons 11 (trans '(0. 0. 1.) nm 0)) ) ) ) ) (princ) ) like this?
    1 point
  7. There is various ways to do this this is just one way. ;;----------------------------------------------------------------------;; ;; Offset line(s) by 10 on both sides (defun C:zzz (/ ss pt1 pt2 mspace myline offsetline1 offsetline2 offsetline1startpt offsetline1endpt offsetline2startpt offsetline2endpt) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (while (setq pt1 (getpoint "\nStart point: ")) (setq pt2 (getpoint pt1 "\n next point: ") ) (command "line" pt1 pt2 "") (setq ent (vlax-ename->vla-object (entlast))) (setq offsetline1 (vla-offset ent 10)) (setq offsetline1startpt (vlax-curve-GetStartPoint (vlax-ename->vla-object (entlast)))) (setq offsetline1endpt (vlax-curve-GetEndPoint (vlax-ename->vla-object (entlast)))) (setq offsetline2 (vla-offset ent -10)) (setq offsetline2startpt (vlax-curve-GetStartPoint (entlast))) (setq offsetline2endpt (vlax-curve-GetEndPoint (entlast))) (princ "\n offset line 1 start point : ") (princ offsetline1startpt) (princ "\n offset line 1 end point : ") (princ offsetline1endpt) (princ "\n offset line 2 start point : ") (princ offsetline2startpt) (princ "\n offset line 2 end point : ") (princ offsetline2endpt) ) ; while (princ) );End
    1 point
×
×
  • Create New...