Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/17/2023 in all areas

  1. Or, use this Ron's mod. by me... (defun c:offslws-out-ins-putlayer (/ _off d o od p s x) (vl-load-com) ;; RJP » 2018-07-26 ;; Offsets a pline inside or out an places the result on layer '3' (defun _off (o d / r) (cond ((= 'list (type (setq r (vl-catch-all-apply 'vlax-invoke (list o 'offset d))))) r)) ) (cond ((and (not (initget "Outside Inside")) (setq p (cond ((getkword "\nOffset [Outside/Inside] <Inside>: ")) ("Inside"))) (setq od (cond ((getdist "\nEnter offset distance: <1.5>")) (1.5))) (setq s (ssget ":L" '((0 . "lwpolyline") (-4 . ">") (90 . 2)))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (setq o (append (_off o (+ od)) (_off o (- od)))) (setq o (mapcar '(lambda (x) (list x (vlax-curve-getarea x))) o)) (cond ((>= (length (setq o (vl-remove 'nil o))) 2) (setq o (vl-sort o '(lambda (r j) (> (last r) (last j))))) (cond ((= p "Outside") (mapcar '(lambda (x) (vla-delete (car x))) (cdr o)) (setq o (entget (vlax-vla-object->ename (caar o)))) ;; Put object on layer '3' (entupd (cdr (assoc -1 (entmod (subst (cons 8 "3") (assoc 8 o) o))))) ) ((= p "Inside") (entdel (vlax-vla-object->ename (caar o))) (setq o (cdr o)) ;; Put object(s) on layer '3' (mapcar '(lambda (x) (entupd (cdr (assoc -1 (entmod (subst (cons 8 "3") (assoc 8 x) x)))))) (mapcar '(lambda (y) (entget (vlax-vla-object->ename y))) (mapcar 'car o) ) ) ) ) ) ((and o (mapcar 'vla-delete (mapcar 'car o))) (print "Could not determine inside or out...") ) ) ) ) ) (princ) ) HTH., M.R.
    1 point
  2. Set the defined layer current via (setvar 'clayer "3") then reset it back at the end to previous layer.
    1 point
  3. @BIGAL Thanks for this handy tip will give this a shot also don't think i've tried it this way before.
    1 point
  4. @Steven P Thanks for your input on this its really helping me get my process refined. I agree it seems a lot smooth if i was to add detail in paper space its just getting my head around isolating layers and freezing viewports thats going to take some getting used to. Ok sounds good i'll give that a go and let you know i get on! Thats a good use of time and tbf my company are all for learning and getting additional skills and training so i might suggest this and see if time allows as it would improve my skills massively if I just had the time in work to test some things out. As a lot of my free time in the evening is dedicated to my CNC work so drawing again at night doesn't seem possible haha.... I'll keep this thread open and let you know how i get on
    1 point
  5. Hi guys, I'm coming back here to say that I found a solution for my issue. In this case: (setq ent (car (nentsel "\nSelect a viewport: "))) - This line prompts the user to select a viewport and stores the selected entity in the variable ent. The function nentsel is used to get a user selection of an entity. (setq center (cdr (assoc 10 (entget ent)))) - Here, the entget function is used to retrieve a list of attributes for the selected entity (ent). Then, the assoc function is used to find the attribute with code 10, which represents the center of the viewport. The center coordinate is stored in the variable center. (setq width (/ (cdr (assoc 40 (entget ent))) 2.0)) - Here, the attribute with code 40 is obtained to determine the width of the selected viewport. The value is divided by 2.0 and stored in the variable width. (setq height (/ (cdr (assoc 41 (entget ent))) 2.0)) - Similarly, the attribute with code 41 is obtained to determine the height of the selected viewport. The value is divided by 2.0 and stored in the variable height. (setq pt1 (- (car center) width)) - It calculates the X coordinate of the top-left point of the viewport by subtracting half of the width (width) from the X coordinate of the center (car center). (setq pt2 (- (cadr center) height)) - It calculates the Y coordinate of the top-left point of the viewport by subtracting half of the height (height) from the Y coordinate of the center (cadr center). (setq pt1-offset (+ pt1 22)) - It adds an offset of 22 units to the calculated X coordinate (pt1) to create a rightward offset. (setq pt2-offset (+ pt2 22)) - It adds an offset of 22 units to the calculated Y coordinate (pt2) to create an upward offset. (setq point (list pt1-offset pt2-offset 0.0)) - It creates a list containing the X, Y, and Z coordinates of the point to be created. The Z value is set to 0.0. (command "_POINT" point) - It executes the "_POINT" command in AutoCAD, creating a point at the specified coordinates given by the point list. In my head, I will use that code to insert a Scale Bar. What will be great to use a standard displacement on the corner. I hope it could be useful to someone else. Many thanks Rodrigo Brigido.
    1 point
  6. Looks like to much code for an intersectwith problem, pick the blue pline then find all intersecting points. The use of (ssget "F" (list of pline points) will get all the crossing objects, you can then use Intersectwith method and for circle will return the 2points. Note error in example dwg lower right circle. Do you know how to write lisp. (setq intpt (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))
    1 point
  7. For front, back, left, right, plan, look into the vpoint command, this can be incorporated into a layout to view in a certain direction from a plan point and at a scale. eg (command "vpoint" "0,0,1") (command "vpoint" "1,0,0") (command "vpoint" "0,1,0") (command "vpoint" "1,1,1") etc
    1 point
  8. Using this as a base .. here you go. (defun c:foo (/ _off d o od p s x) ;; RJP » 2018-07-26 ;; Offsets a pline inside or out an places the result on layer '3' (defun _off (o d / r) (cond ((= 'list (type (setq r (vl-catch-all-apply 'vlax-invoke (list o 'offset d))))) (car r))) ) (cond ((and (not (initget "Outside Inside")) (setq p (cond ((getkword "\nOffset [Outside/Inside] <Inside>: ")) ("Inside") ) ) (setq od (cond ((getdist "\nEnter offset distance: <1.5>")) (1.5) ) ) (setq s (ssget ":L" '((0 . "lwpolyline") (-4 . ">") (90 . 2)))) ) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (setq o (mapcar '(lambda (x) (cond ((setq d (_off o (x od))) (list d (vlax-curve-getarea d))))) (list + -) ) ) (cond ((= 2 (length (setq o (vl-remove 'nil o)))) (setq o (vl-sort o '(lambda (r j) (< (last r) (last j))))) (cond ((= p "Outside") (setq o (reverse o)))) (vla-delete (caadr o)) (setq o (entget (vlax-vla-object->ename (caar o)))) ;; Put object on layer '3' (entmod (append o '((8 . "3")))) ) ((and o (mapcar 'vla-delete (mapcar 'car o))) (print "Could not determine inside or out...") ) ) ) ) ) (princ) ) (vl-load-com)
    1 point
×
×
  • Create New...