Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/06/2023 in all areas

  1. I wouldn't say a wast of time. and its only like what 2 or 3 months old? just imagine what it will be able to do in like a year or two. cool resource indeed but if using it to learn coding. keep in mind (just like here) it might not be giving you the right information. but the chat isn't going to correct itself. Were as if someone post here in error or if someone doesn't agree with the method its a good chance to get a follow up post.
    2 points
  2. "Give a man a fish you feed him for a day... Teach a man to fish and he can feed himself for the rest of his life.." I am a novice (if that) at writing code. I just found that CHATGBT (ai) can write autolisp code. ChatGBT You have to be able to verbalize what you are after using decent descriptions (which mods have to dig for when helping end users such as myself define our needs) I'll admit it misses the mark more than not but what I have found <for me> is that it gives me enough of a foundation that I can troubleshoot it myself and get a routine working... Wanted to let everyone know there is a tool that can help those of us who are "learning to walk" as it were.. Even if it's a simple as how do I do "X" in lisp... I'm hoping that like other AI sites that it will get better in time... If you know nothing, probably not going to help since you cannot troubleshoot... If you know a lot you'll see the coding errors right off and think it's a waste of time... If you know a little and are trying to learn it is a cool resource... I used it to write some Powershell code and it did a really good job. FWIW..
    1 point
  3. bad argument type: numberp: nil - the LISP is wanting a number and isn't getting one, nil means it is getting a 'nil' - nothing at all. The only part I deal with number are in the colour codes so that's where the error is.... and the one check I didn't do must be the problem.... if the objects are 'bylayer' colour then the colour code returned is a nil. Try this: Set the line (setq col "21") to be whatever you want, keeping the suffix as a string (enclosed in quotes) (defun c:lay2x ( / enx idx lay sel col newlayname) (if (setq sel (ssget "_:L" '((8 . "~X*")))) ;; Select objects if layer doesn't begin with X (repeat (setq idx (sslength sel)) ;; Loop through selection set (setq enx (entget (ssname sel (setq idx (1- idx)))) lay (assoc 8 enx) col (assoc 62 enx) ) ; end setq (if (= nil col) (setq col "21") (setq col (rtos (cdr (assoc 62 enx)))) ) (setq newlayname (strcat "X" (cdr lay) ) ) ; add X to start (setq newlayname (vl-string-right-trim "-0123456789" newlayname)) ; trim away suffix numbers and suffix '-' (setq newlayname (strcat newlayname "-" col)) ; add in colour suffix. (entmod (subst (cons 8 (matchlayer (cdr lay) newlayname)) lay enx)) ; update entity definition ) ; end repeat ) ; end if (princ) )
    1 point
  4. Their is alot more to offset command. have to check the polyline's direction. (is it clockwise or counter clock wise) then the vla-offset its self is a variant (because their can be multiple offsets) unless you use vlax-invoke then its a list. you shouldn't have multiple offsets unless you have weird shape that has a choke point like this. example creates two new polylines. I test for this in my lisp so it will alert with a popup saying "More Than one Offset Detected" and quit. but this should never happen. (defun c:Fence_Update (/ i obj1 obj2 ent off blug) (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))) (setq i 0) ;; parameter index (setq obj1 (vlax-ename->vla-object (car (entsel "\nSource Polyline: "))) obj2 (vlax-ename->vla-object (car (entsel "\nFence Polyline: "))) ) (setq off (vlax-invoke obj1 'offset (if (CW obj1) 2.0 -2.0))) ;offset to inside (if (<= (length off) 1) (setq bulg (mapcar 'cdr (vl-remove-if-not '(lambda (x)(= (car x) 42)) (entget (vlax-vla-object->ename (setq off (car off))))))) (progn (alert "\nMore Than one Offset Detected") (quit) ) ) (vla-put-Coordinates obj2 (vla-get-Coordinates off)) (foreach b bulg (vla-setbulge obj2 i (nth i bulg)) (setq i (1+ i)) ) (vla-delete off) (vla-endundomark Drawing) (princ) ) ;;----------------------------------------------------------------------------;; ; Check Polylines direction is CW or CCW - Writer Evgeniy Elpanov By Bill Gilliss ;(vla-offset (vlax-ename->vla-object ent) (if (CW ent) -0.01 0.01)) (defun CW (poly / lw lst LL UR) (if (= (type poly) "ENAME") (setq lw (vlax-ename->vla-object poly)) (setq lw poly) ) (vla-GetBoundingBox lw 'LL 'UR) (setq LL (vlax-safearray->list LL) UR (vlax-safearray->list UR) lst (mapcar (function (lambda (x) (vlax-curve-getParamAtPoint poly (vlax-curve-getClosestPointTo poly x) ) ) ) (list LL (list (car LL) (cadr UR)) UR (list (car UR) (cadr LL)) ) ) ) (if (or (<= (car lst) (cadr lst) (caddr lst) (cadddr lst)) (<= (cadr lst) (caddr lst) (cadddr lst) (car lst)) (<= (caddr lst) (cadddr lst) (car lst) (cadr lst)) (<= (cadddr lst) (car lst) (cadr lst) (caddr lst)) ) ;_ or t ) )
    1 point
  5. Try this opened in Briscad no probs. The page errors may be about language settings on your PC, did you get it from someone who works in non english. floorplan2.dwg
    1 point
  6. Maybe this will help you along a bit? MHUPP will no doubt come up with something nicer - he usually does. Just making assumptions from MHUPPS questions, The pattern doesn't mater so much here Adding an X to start with Adding just the colour code to finish (1 for red, ->254 for grey) - removing -any- suffix number and '-' Reversed to remove -any- X at the start of the layer and -any- number at the end replaced by'21' Done this so that newlayname shows how I was building up the new layer name. Commented out original lines where not needed and additional lines are not indented. (defun c:lay2x ( / enx idx lay sel col newlayname) (if (setq sel (ssget "_:L" '((8 . "~X*")))) ;; Select objects if layer doesn't begin with X (repeat (setq idx (sslength sel)) ;; Loop through selection set (setq enx (entget (ssname sel (setq idx (1- idx)))) lay (assoc 8 enx) col (rtos (cdr (assoc 62 enx))) ; get colour as a string ) ; end setq (setq newlayname (strcat "X" (cdr lay) ) ) ; add X to start (setq newlayname (vl-string-right-trim "-0123456789" newlayname)) ; trim away suffix numbers and suffix '-' (setq newlayname (strcat newlayname "-" col)) ; add in colour suffix. ;; (entmod (subst (cons 8 (matchlayer (cdr lay) (strcat (cdr lay) "-PR"))) lay enx)) (entmod (subst (cons 8 (matchlayer (cdr lay) newlayname)) lay enx)) ; update entity definition ) ; end repeat ) ; end if (princ) ) (defun c:x2lay ( / enx idx lay sel newlaynbame) (if (setq sel (ssget "_:L" '((8 . "X*")))) ;; Select layers beginning with X (repeat (setq idx (sslength sel)) ;; Loop thrpugh selection set (setq enx (entget (ssname sel (setq idx (1- idx)))) lay (assoc 8 enx) ) ; end setq (setq newlayname (vl-string-left-trim "X" (cdr lay))) ; trim away X prefix (setq newlayname (vl-string-right-trim "-0123456789" newlayname)) ; trim away suffix numbers and suffix '-' (setq newlayname (strcat newlayname "-21")) ; add in '21' suffix as a string. ;; (entmod (subst (cons 8 (matchlayer (cdr lay) (substr (cdr lay) 1 (- (strlen (cdr lay)) 3)))) lay enx)) (entmod (subst (cons 8 (matchlayer (cdr lay) newlayname)) lay enx)) ; update entity definition ) ; end repeat ) ; end if (princ) ) (defun matchlayer ( src new ) (or (tblsearch "layer" new) (entmake (subst (cons 2 new) (cons 2 src) (vl-remove-if '(lambda ( x ) (member (car x) '(-1 5 102 360))) (entget (tblobjname "layer" src))) ) ) ) new ) ps. this wasn't me, I wasn't here.
    1 point
×
×
  • Create New...