Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/29/2024 in all areas

  1. With this? (defun draw_pt (pt col / rap) (setq rap (/ (getvar "viewsize") 50)) (foreach n (mapcar '(lambda (x) (list ((eval (car x)) (car pt) rap) ((eval (cadr x)) (cadr pt) rap) (caddr pt) ) ) '((+ +) (+ -) (- +) (- -)) ) (grdraw pt n col) ) ) (defun c:partial_cut ( / ss ent vlaobj pt_brk pt_brk2 tmp_brk new_ent e_last) (vl-load-com) (princ "\nSelect a curve object.") (while (not (setq ss (ssget "_+.:E:S" (list (cons -4 "<AND") (cons 0 "*POLYLINE,LINE,ARC") (cons -4 "<NOT") (cons -4 "&") (cons 70 112) (cons -4 "NOT>") (cons -4 "AND>") ) ) ) ) ) (redraw (setq ent (ssname ss 0)) 3) (setq vlaobj (vlax-ename->vla-object ent) ) (initget 1) (while (or (equal (setq pt_brk (vlax-curve-getClosestPointToProjection vlaobj (trans (getpoint "\nGive the first point: ") 1 0) '(0.0 0.0 1.0))) (vlax-curve-getStartPoint vlaobj) 1E-13) (equal pt_brk (vlax-curve-getEndPoint vlaobj) 1E-13) ) (initget 1) ) (cond (pt_brk (draw_pt (trans pt_brk 0 1) 3) (initget 1) (while (or (equal (setq pt_brk2 (vlax-curve-getClosestPointToProjection vlaobj (trans (getpoint "\nGive the second point: ") 1 0) '(0.0 0.0 1.0))) (vlax-curve-getStartPoint vlaobj) 1E-13) (equal pt_brk2 (vlax-curve-getEndPoint vlaobj) 1E-13) ) (initget 1) ) (if pt_brk2 (progn (command "_.undo" "_begin") (draw_pt (trans pt_brk2 0 1) 3) (if (> (vlax-curve-getParamAtPoint vlaobj pt_brk) (vlax-curve-getParamAtPoint vlaobj pt_brk2)) (setq tmp_brk pt_brk2 pt_brk2 pt_brk pt_brk tmp_brk) ) (command "_.break" (cons ent (list (trans pt_brk 0 1))) "_first" "_none" (trans pt_brk 0 1) "_none" (trans pt_brk 0 1)) (setq new_ent (entlast)) (command "_.break" (cons new_ent (list (trans pt_brk2 0 1))) "_first" "_none" (trans pt_brk2 0 1) "_none" (trans pt_brk2 0 1)) (setq e_last (entlast)) (entdel e_last) (setq new_ent (entlast)) (entdel e_last) (sssetfirst nil (ssadd new_ent (ssadd))) (initget "Yes No") (if (eq (getkword "\nErase it? [Yes/No] <No>: ") "Yes") (progn (sssetfirst nil nil) (entdel new_ent)) (sssetfirst nil nil) ) (command "_.undo" "_end") (redraw) ) ) ) ) (redraw ent 4) (prin1) )
    1 point
  2. I no longer have Plant 3D loaded, maybe I'll check into getting it again. This is pretty old now, might be something newer. How to script components for AutoCAD Plant 3D (autodesk.com) A little newer. How can I build a own Library of custom Parts written as python scripts? - Autodesk Community - AutoCAD Plant 3D Even more recent and even more if you check out the related videos. AutoCAD Plant 3D Tutorial: Python Integration in AutoCAD Plant 3D. A Step-by-Step Guide (youtube.com)
    1 point
  3. 1st answer is that ChatGP is very unreliable so many times code is totally rewritten. 2nd "selects entities of a specified length from the entire drawing" length is not a searchable property must get object 1st then can get Length property. You dont say what you want to do with answer so just made a list of lengths. (defun c:wow ( / ss len) (setq ent (entsel "\nPick a object for layer ")) (setq lay (cdr (assoc 8 (entget (car ent))))) (setq ss (ssget (list (cons 0 "LWPOLYLINE,line,circle,Arc")(cons 8 Lay)))) (if (= ss nil) (progn (alert "You have not selected any correct objects \nWill now exit")(exit)) ) (setq lst '()) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq objname (vlax-get obj 'objectname)) (cond ((= objname "AcDbArc")(setq len (vlax-get obj 'Arclength))) ((= objname "AcDbLine")(setq len (vlax-get obj 'length))) ((= objname "AcDbCircle")(setq len (vlax-get obj 'Circumference))) ((= objname "AcDbPolyline")(setq len (vlax-get obj 'length))) ) (setq lst (cons len lst)) ) (princ) )
    1 point
×
×
  • Create New...