Leaderboard
Popular Content
Showing content with the highest reputation on 02/09/2023 in all areas
-
You already had it @hosneyalaa no need for a counter. (princ (strcat "\nTotal of " (itoa i) " Object(s) were deleted ... " )) You can select blocks that don't have attributes directly with ssget (66 . 0) so you then don't have to test for attributes and just delete everything in the selection set. ;;----------------------------------------------------------------------------;; ; DELETE SELECTED BLOCK THAT DON'T HAVE ATTRIBUES (defun c:deleteC (/ e i ss) (setq ent (car (entsel "\nSelect Block"))) (setq blkname (cdr (assoc 2 (entget ent)))) (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 blkname) '(66 . 0)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (entdel ent) ) (princ (strcat "\n0 " blkname " Block(s) Deleted ... ")) ) (if ss (princ (strcat "\n" (itoa (sslength ss)) " " blkname " Block(s) Deleted ... ")) ) (princ) )2 points
-
TRY (defun c:deleteC ( / E I SS) (if (setq ss (ssget '((0 . "INSERT")))) (progn (setq n 0) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (= (vlax-invoke e 'GetAttributes) nil) (progn (setq n (+ 1 n)) (vla-delete e) ) ) ) ) ) (princ (strcat "\nTotal of " (itoa n) " Object(s) were deleted ... " )) (princ) )2 points
-
I made something that I quite like. It works on your dwg example. It could use some work to make it more versatile. - The code works only for polylines. - Only for horizontal/vertical lines. - There's hardly any error check. Use it as intended, or I don't know what will happen. Command CCF - user sets a distace dist1 - user selects the polyline - Now pick corner points p1. don't pick the end of the polyline. It only expects corner points (best put on OSNAP) - p1 now gets replaced by p2 p4 p3 I haven't looked well at the other replies. I'll just assume I did it a little different (vl-load-com) ;; returns a list of coordinates. But we replace 1 coordinate by 3 points (defun move_vertex_add_custom_chamfer ( lst ind p1 p2 p3 / new_lst i) (setq new_lst (list)) (setq i 0) (repeat (/ (length lst) 2) (if (= i (* 2 ind)) ;; add the 3 points (setq new_lst (append new_lst (list (nth 0 p1) (nth 1 p1) (nth 0 p2) (nth 1 p2) (nth 0 p3) (nth 1 p3) ))) ;; copy list (setq new_lst (append new_lst (list (nth i lst) (nth (+ i 1) lst) ))) ) (setq i (+ i 2)) ) new_lst ) ;; CCF for Custom ChamFer (defun c:ccf ( / dist dist2 pline p1 param1 d1 p2 p3 ang1 ang2 coords) ;; User enters the distance / offset (setq dist (getdist "\nDistance to custom chamfer: ")) ;; user selects polyline. (setq pline (car (entsel "\nSelect polyline: "))) (while (setq p1 (osnap (getpoint "\nSelect corner point: ") "_end")) ;; select corner (setq param1 (vlax-curve-getParamAtPoint pline p1)) ;; d1 = the distance along the path of the polyline at p1 (setq d1 (vlax-curve-getDistAtPoint pline p1)) ;; now p2 = d1 + offset distance, p1 = d1 - offset distance, (setq p2 (vlax-curve-getPointAtDist pline (- d1 dist) )) (setq p3 (vlax-curve-getPointAtDist pline (+ d1 dist) )) ;;;; now check the angles. ;;;; angle from previous endpoint to p1 ;;(setq ang1 (angle ;; (vlax-curve-getPointAtParam pline (- param1 1)) ;; (vlax-curve-getPointAtParam pline param1) ;;)) ;; ;; ;; angle from p1 to newt endpoint ;;(setq ang2 (angle ;; (vlax-curve-getPointAtParam pline (+ param1 1)) ;; (vlax-curve-getPointAtParam pline param1) ;;)) ;; TODO: make this work for other angles; not just horizontal/vertical ;; We look for p4, which cas 1 coordinate of p2 and 1 of p3 (if (= (nth 0 p1) (nth 0 p2) ) ;; p1-p2 is horizontal, so we take y-value of p2 and x-value of p3 (setq p4 (list (nth 0 p3) (nth 1 p2) )) ;; else the opposite (setq p4 (list (nth 0 p2) (nth 1 p3) )) ) ;; read vertex coordinates; replace the selected point. (setq coords (vlax-get (vlax-ename->vla-object pline) 'coordinates)) ;; Remove the chosen point, replace it by the 3 "chamfered" points (setq new_coords (move_vertex_add_custom_chamfer coords param1 p2 p4 p3)) (vlax-put (vlax-ename->vla-object pline) 'coordinates new_coords) ;replace the coordinate list ) )2 points
-
thank you all for your help! i got all your lisp and will use it depending on what the drawing is presented to me, polyline or line. it's really close to what i wanted and can work as intended. and i am already happy with what you guys gave me. PS: but for expert LISP writers out there here's the more detailed explanation on how i wanted the command SUMMARY: A custom command just like chamfer or fillet that does a "notch" instead of an arc (for fillet) or a diagonal (for chamfer) Details: can work on lines or polylines case 1 if objects is short to the intersection it extends it up to the notch case 2 if objects is longer than the intersection it trims it up to the notch case 3 if lines meet at intersection it creates the notch case 4 if objects are lines everything are created as lines (just like chamfer would do) case 5 if one object is polyline it joins objects into the polyline (just like chamfer would do) case 6 in case 0 distance is used it will extend or trim the line to meet at intersection (just like fillet and chamfer) Procedure: type in command type in distance / use previous distance (distance is recorded in case of multiple uses (just like chamfer do) pick object 1 pick object 2 end.1 point
-
Very late response but OVERKILL might be what you are looking for I tend to make the resolution larger so more things get combined at once.1 point
-
apart from it being awful to read... can you edit the code above to replace the tabbed indentations with perhaps a space for each? What does zwcad say / report when this doesn't work? what is the error - just gives us some clue where to look for a solution....1 point
-
Hi, I would prefer two steps: 1) check, if there is something on z/=0 Use systemvariables EXTMIN and EXTMAX, both tell you the hightest/lowest x,y,z Could also be used to see, if there are objects outside the defined drawing area 2) if any of extmin or extmax tells you, there is something with z/=0, check the bounding-boxes : (defun c:test (/ j k minp maxp) (vl-load-com) (vlax-for obj (vla-get-blocks ; <-- only checks block-definitions (vla-get-activedocument (vlax-get-acad-object)) ) ;_ end of vla-get-blocks (setq bbox (vl-catch-all-apply 'vla-getboundingbox (list obj 'j 'k)) ) ;_ end of setq (if (vl-catch-all-error-p bbox) () (progn (setq zminp (caddr (vlax-safearray->list j))) (setq zmaxp (caddr (vlax-safearray->list k))) (if (OR (< zminp -1) (> zmaxp 1)) (princ (strcat "\nObject: " (if (vl-catch-all-apply 'vla-get-effectivename (list obj)) (vla-get-effectivename obj) (vla-get-name obj) ) ;_ end of if " Z-min: " (rtos zminp) " Z-max: " (rtos zmaxp) ) ;_ end of strcat ) ;_ end of princ ) ;_ end of if ) ;_ end of progn ) ;_ end of if ) ;_ end of vlax-for ) ;_ end of defun (c:test) regards Wolfgang1 point
-
That works brilliantly thank you very much. I removed the "_non" from the boundary command and then it worked perfectly. (command "_.boundary" "_a" "_i" "_n" "" "" cen "") Thank you so much you are a hero1 point
-
HI TRY (defun c:deleteC ( / E I SS) (if (setq ss (ssget '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (= (vlax-invoke e 'GetAttributes) nil) (vla-delete e) ) ) ) (princ) )1 point
-
Change view front? Everything should be on one line if they are on the same elevation. (defun C:FrontView () (command-s "-vpoint" "0,-1,0") )1 point
-
Thickness is a vertical height of a line or pline, used as a 2.5D to look like 3D.. Do you mean width or line weight.1 point
-
This should do it select two polylines obj1 obj2 offset obj1 in 2 feet checks if offset only created 1 polyline gets the geocenter of offset polyline p1 uses boundary command with new point to create a boundary (offset + boundary = area you want) gets bulg information from boundary poly p2 deletes 2 ft offset poly p1 updates polyline obj2 with boundary cords of poly p2 deletes boundary polyline p2 updates bulg info to obj2 -Edit You might have to isolate the two layers for the boundary to work correctly tho it is set to ignore islands. Also since im using BricsCAD the boundary command might be diffrent in AutoCAD. (command "_.Boundary" "_A" "_I" "_N" "" "_non" cen "") use "-boundary" to Enter the choices at the command prompt -Edit layiso update UFP-iso.lsp1 point
-
See attached Please show us some real and true sample.dwg . I suppose this notch are cut to bend the metal or whatever material to become a 4 sided PAN from a Flat sheet . If it is so the polylines will be closed. But maybe despite it is closed, the notch could be at some , and not all corners .1 point
-
It can but only matches same values. even if you tell AutoCAD to draw a line from 50,50 it might be 50.00000000000001, 50.000000000000000000001 and thats not the same as 50,50. With equal you can give it a fuzz distance. This (equal 50 # 0.01) will return T for any number between 50.01 - 49.991 point