Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/03/2019 in all areas

  1. That is correct n = number to check ln = low range number un = upper range number
    1 point
  2. Because this is painful when you have a lot of objects selected. "tombu" Thanks for the option of the macro. I tried this and it works. Thanks to both for your input.
    1 point
  3. YES been done before I answered so did lee-mac I think and a few others, I am pretty sure does what you want or is very close. Will try to find. Search here PLOFFS
    1 point
  4. Multi GETVALS.lspTry this (defun c:plhook ( / plent pt1 pt2 pt3 x pt5 add ang1 ang2) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (while (setq plent (entsel "Pick pline Enter to exit")) (if (/= plent nil) (progn (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq ans (AH:getvalsm (list "Enter length" "Hook length " 5 4 "30" "Radius" 5 4 "25" ))) (setq add (atof (nth 0 ans))) (setq rad (atof (nth 1 ans))) (setq pt5 (polar pt1 (+ (* 0.25 pi) ang1) add)) ; 135 degrees (command "line" pt1 pt5 "") ; new line (setq ans (ah:butts but "V" '("Flip " "Yes" "No"))) (if (= "No" ans) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") (setq pt5 (polar pt4 (+ (* 0.25 pi) ang2) add)) ; other end (command "line" pt4 pt5 "") (setq ans (ah:butts but "V" '("Flip " "Yes" "No"))) (if (= "No" ans) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") (command "fillet" "Polyline" "r" rad (car plent)) ) ) ) ) (c:plhook) Multi radio buttons.lsp
    1 point
  5. Re doing was typo in code. (defun c:plhook ( / plent pt1 pt2 pt3 x pt5 add ang1 ang2) (while (setq plent (entsel "Pick pline Enter to exit")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq add (getreal "Enter distance to add on")) (setq pt5 (polar pt1 (+ (* 0.25 pi) ang1) add)) ; 135 degrees (command "line" pt1 pt5 "") ; new line (setq ans (getstring "is line ok Y or N")) ; is it in correct direction (if (= "Y" (strcase ans)) ; y or Y (princ "ok") (command "mirror" "Last" "" pt1 pt2 "Y") ; flip line ) (setq pt5 (polar pt4 (+ (* 0.25 pi) ang2) add)) ; other end (command "line" pt4 pt5 "") (setq ans (getstring "is line ok Y or N")) (if (= "Y" (strcase ans)) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) ) ) (c:plhook)
    1 point
  6. This is a good time to start to learning lisp, without getting to smart about the task you want a extra line either left or right of a pline end. This would be done using the endpoint and startpoint of a pline, then using the polar command working out a new point adding the line then to the pline. So a start get the pline vertice points this allows you to work out the pline end segments angles. using polar command draw the new line +45 to the angle ask is it correct direction if not erase and use -45 to the angle. Ok so some code (setq plent (entsel "Pick pline")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) ; ((156.0 78.0) (307.957959107735 78.0) (307.957959107735 203.997487733392)) ; this is a L pline 3 points (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq add (getreal "Enter distance to add on")) ok your turn Pt5 using polar command then line pt1 pt5 if wrong direction use mirror command note angle must be in radians so use (* 0.75 pi) for 135 degrees. Please to others have to start at some point. Complete code to do what you want it is short.
    1 point
  7. You could approach this in one of two ways, either through Vanilla AutoLISP or through Visual LISP, I'll show you both. Firstly, we need to get a block to work with, for this we can use entsel. (setq bEnt (car (entsel "\nSelect Block: "))) Notice I use 'car' to retrieve the entity name, as entsel will return a two element list upon a successful pick, the first item being the entity name of the object picked and the second item being the point at the center of the aperture that was picked. We would also need to check that the entity picked is indeed a block, and that it has attributes: (if (and (setq bEnt (car (entsel "\nSelect Block: "))) (eq "INSERT" (cdr (assoc 0 (entget bEnt)))) (= 1 (cdr (assoc 66 (entget bEnt)))) ) This is how I might start the code, using an IF statement to make sure that the user picks an entity and that the entity picked is indeed an attributed block. For more reference on the DXF codes used, see here. Ok, so now that we have our block we can iterate through its attributes, the attributes can be found by using entnext on the INSERT entity name. We can iterate through all the attributes in this way, by using entnext on the previous attribute entity encountered. When we reach a 'SEQEND' entity, we have iterated through all the attributes that the block contains (we can then get back to the parent block entity using DXF -2 on the SEQEND entity). In code, we can concisely write this as: (while (not (eq "SEQEND" (cdr (assoc 0 (entget (setq bEnt (entnext bEnt) ) ) ) ) ) ) ... ) In this way, the WHILE loop will continue until the SEQEND entity is reached. Notice that we also set the variable 'bEnt' to itself each time so that we are using entnext on the previous subentity retrieved. In the loop we can now operate on our attributes, for example retrieving the value of attribute with tag 'TAG': (while (not (eq "SEQEND" (cdr (assoc 0 (entget (setq bEnt (entnext bEnt) ) ) ) ) ) ) (if (eq "TAG" (cdr (assoc 2 (entget bEnt)))) (setq AttVal (cdr (assoc 1 (entget bEnt)))) ) ) Or perhaps changing its value to something else: (while (not (eq "SEQEND" (cdr (assoc 0 (entget (setq bEnt (entnext bEnt) ) ) ) ) ) ) (if (eq "TAG" (cdr (assoc 2 (entget bEnt)))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 "Lee Mac") (assoc 1 (entget bEnt)) (entget bEnt) ) ) ) ) ) ) ) Now for the Visual LISP way: Now that we want to operate on the block through Visual LISP, we need a Visual LISP Object to work with: (setq bObj (vlax-ename->vla-object bEnt)) We could also test to make sure that the block has attributes using: (eq :vlax-true (vla-get-HasAttributes bObj)) Now, iterating through the attributes is slightly easier in VL: (foreach att (vlax-invoke bObj 'GetAttributes) ... ) Or to include Constant Attributes also: (foreach att (append (vlax-invoke bObj 'GetAttributes) (vlax-invoke bObj 'GetConstantAttributes)) ... ) Now that we have bound each attribute object to the symbol 'att' we can operate on these objects within the foreach loop; for example to retrieve the value of an attribute with tag string "TAG": (foreach att (append (vlax-invoke bObj 'GetAttributes) (vlax-invoke bObj 'GetConstantAttributes)) (if (eq "TAG" (vla-get-TagString att)) (setq attVal (vla-get-TextString att)) ) ) Notice that we use vlax-invoke in this case, as opposed to vlax-invoke-method or rather just vla-getAttributes. This is because the return of vlax-invoke is a list, which is much easier to deal with using standard Vanilla AutoLISP functions. If we were to use vlax-invoke-method, or vla-getAttributes we would need to convert the variant that is returned into a list that we can manipulate: (foreach att (vlax-safearray->list (vlax-variant-value (vla-getAttributes bObj) ) ) (if (eq "TAG" (vla-get-TagString att)) (setq attVal (vla-get-TextString att)) ) ) This should get you going, if you get stuck, just ask. Lee
    1 point
×
×
  • Create New...