Leaderboard
Popular Content
Showing content with the highest reputation on 05/03/2023 in all areas
-
After a significant amount of work undertaken on & off over the last few months, I'm finally ready to release V1.5 of this program - I have updated the first post of this thread with the new version, or you may download it from my site here. New features include: Incrementing by layout (in addition to by drawing) Referencing existing values (facilitating easy batch prefixing/suffixing of attribute values) Control over the drawing process order I have also addressed many of the bugs which had been reported in the years since the last version was released.2 points
-
1 point
-
Weclome to CADTutor ;; Change this (setq space (entget (ssname ss iter))) (command "area" "o" space) (setq areatot (+ areatot (getvar "area"))) ;; To this (setq space (ssname ss iter)) (setq areatot (+ areatot (vlax-curve-getarea space)))1 point
-
Try the following sample - (defun c:rnb ( / ent enx new opt ) (setq opt '( ;; Keyword . Block Name ("Main" . "Main-Title-block") ("Sub" . "Sub-Title-block") ) ) (cond ( (null (setq opt (vl-remove-if '(lambda ( x ) (tblsearch "block" (cdr x))) opt))) (princ "\nAll target block names already exist in the active drawing.") ) ( (progn (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block to be renamed: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil ) ( (/= "INSERT" (cdr (assoc 0 (entget ent)))) (princ "\nThe selected object is not a block.") ) ) ) ) (null ent) ) (princ "\n*Cancel*") ) ( (progn (initget (LM:lst->str (mapcar 'car opt) " ")) (setq new (getkword (strcat "\nNew block name [" (LM:lst->str (mapcar 'car opt) "/") "]: "))) ) (setq enx (entget (cdr (assoc 330 (entget (tblobjname "block" (LM:name->effectivename (cdr (assoc 2 (entget ent)))))))))) (entmod (subst (cons 2 (cdr (assoc new opt))) (assoc 2 enx) enx)) ) ( (princ "\n*Cancel*")) ) (princ) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename ( blk / rep ) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) ;; List to String - Lee Mac ;; Concatenates each string in a supplied list, separated by a given delimiter ;; lst - [lst] List of strings to concatenate ;; del - [str] Delimiter string to separate each item (defun LM:lst->str ( lst del ) (if (cdr lst) (strcat (car lst) del (LM:lst->str (cdr lst) del)) (car lst) ) ) (princ)1 point
-
I see that you make very good use of your rainy days.1 point
-
1 point
-
This may be a useful starting point. You need block name and attribute tagname. ; simple update 1 attribute across all layouts ; By Alan H Nov 2020 (defun c:1rev ( / len lay plotabs newstr tabname oldtagn ss1 att x y) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq tabs (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))) (setq y 0) (setq ent (nentsel "\nPick an attribute ")) (setq ent2 (ssname (ssget (cadr ent)) 0)) (setq bname (cdr (assoc 2 (entget ent2)))) (setq oldtagn (cdr (assoc 2 (entget (car ent))))) (SETQ NEWSTR (getstring "\nEnter new string ")) (repeat (vla-get-count tabs) (vlax-for lay tabs (setq x (vla-get-taborder lay)) (setq tabname (vla-get-name lay)) (if (and (= y x) (/= tabname "Model")) (progn (setvar "ctab" tabname) (if (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname)))) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes) (if (= oldtagn (strcase (vla-get-tagstring att))) (vla-put-textstring att newstr) ) ) ) ) ) ) (setq y (+ y 1)) ) ) (c:1rev)1 point
-
Thanks @ronjonp - I would have modified the code in exactly the same way.1 point
-
It's raining here so I created the attached Excel worksheet. The user enters the radius of the cylinder, the holes, the vertical spacing and the angle between the holes. Cell A7 provides the center to center distance. To get the shortest distance from hole edge to hole edge we need to find a point on the edge that is located at the same slope as the line between the two slopes. The variable "a" specifies the y coordinate of a point on the hole edge. Its x and y values are in cells A17:B17. To find the point on the slope line we need to make the value of cell A25 = 0. Goal seek can be used to determine "a" and therefor the shortest distance. The image above has the results when a = .5 and there's an error in slope of 3.289... Here's the input to Goal Seek. Below is the results of goal seek. The result are consistent with @SEANT's ddistance between 2 holes.01.xlsxrawing.1 point
-
I had an 'Unroll Developable Surface' routine in the works for numerous years now. To this day, unfortunately, it is still a bit buggy. I'll look it over again, see if something new catches my eye on where the bugs may lie. At some point I may post it as Alpha Release software here. The @lrm That geometry was derived by mapping UV coordinates of the Solid Cylinder's face to an unrolled surface with equivalent UV parameters. I think the process could be setup in EXCEL using cylindrical coordinates. How geeky would I sound by saying that would be a fun rainy weekend project.1 point
-
@SEANT Good catch! I tested your shape by determining the coordinates of a point with a y value of 1/2 the radius of the hole. The x coordinates would be: = (1/2)*radCyl* 2*asin(sqrt(radHole^2 - (radHole/2)^2)/radCyl) For the example in your file, radius cylinder = 100, radius hole = 75 x = 70.69517, y = 37.5 Here's the point added to your drawing. It's right on! Red = circle, magenta = ellipse, what is the equation of your white curve?1 point
-
All interesting stuff and excellent analysis. I look into the files and tried some additional stuff and found a point of clarification. The ‘Unrolled’ bicylindrical curve is not an ellipse. At small relative sized cylinder pairs it does appear quite ellipse like. Use of an ellipse as a proxy may be well within tolerance. At larger relative radius sizes, though, the difference may become more important. LargerRelativeSize.dwg1 point
-
(defun c:foo nil (setvar 'cmdecho 0) (foreach l (layoutlist) (setvar 'ctab l) (setvar 'psltscale 0) (command "_.regenall")) (setvar 'cmdecho 1) (princ) )1 point
-
The ellipses in "cylinder with holes.02" have the wrong major axis dimensions. I forget the values I used to draw the ellipse. The "...03" version is correct. But, as noted, the ellipses were not created using the parametric features of AutoCAD. I calculated the ellipse dimensions manually for that file. If you edit the parametric dimensions the hole location will update correctly but the ellipses will not change. I've modified the parametric drawing to create parametrically driven ellipse dimensions by referencing a rectangle that is constrained and has the major and minor dimensions of the computed ellipse. There is the risk that the ellipse may rotate within the rectangle as dimensions are changed but some testing showed good results. Try iit out! Of course, you can use the Autolisp program. I've done some testing with various cylinder and hole dimensions and it seems to yield accurate results but you should test it yourself. cylinder with holes.03.dwg1 point
-
1 point
-
@dude I'm glad you found the drawing helpful. I thought I have some fun with this problem so I wrote an AutoLISP program that draws the two ellipses given the cylinder diameter, hole diameter, angle and vertical offset. It creates a dim line for the center to center distance and displays the value in an alert box. Just use appload and load "cylinder holes.01.lsp" then give the holes command in AutoCAD. The distance between the closest points on the two ellipses is more complicated. You can draw a line from the center of one ellipse to the center of the other ellipse then use trim. The length of the trimmed line is the dimension I think you are looking for. To have the program calculate the intersection points of the line and the ellipses is a bit more work as noted here. If you are interested I could add that feature. If you have any question about how I determined the ellipse dimensions let me know. (defun c:holes (/ dCyl dHole ang dV dH p1 p2 d p3 eMajor ellipse1Pt1 ellipse1Pt2 ellipse2Pt1 ellipse2Pt1 msg) ; calculates hole placement on cylinder (setq dCyl (getreal "\nEnter cylinder diameter. ") dHole (getreal "\nEnter hole diameter. ") ang (getreal "\nEnter offset angle between holes (degrees). ") dV (getreal "\nEnter vertical offset for second hole. ") dH (/ (* (/ dCyl 2.) ang pi) 180.) p1 '(0 0) ; center ellipse 1 p2 (list dh dv) ; center ellipse 2 d (distance p1 p2) ; distance between centers p3 (mapcar '+ p1 (list 0 d)) ; point for placing dim line eMajor (* dCyl (asin (/ dHole dCyl))) ;ellipse major diameter ellipse1Pt1 (mapcar '+ p1 (list (/ eMajor 2) 0.0)) ellipse1Pt2 (mapcar '+ p1 (list 0.0 (/ dHole 2))) ellipse2Pt1 (mapcar '+ p2 (list (/ eMajor 2) 0.0)) ellipse2Pt2 (mapcar '+ p2 (list 0.0 (/ dHole 2))) ) ;(command "_circle" p1 "d" dHole) ;(command "_circle" p2 "d" dHole) (command "_ellipse" "c" p1 ellipse1Pt1 ellipse1Pt2) (command "_ellipse" "c" p2 ellipse2Pt1 ellipse2Pt2) (command "_dimaligned" p1 p2 p3 "") (setq msg (strcat "Center to center distance = " (rtos d 2 4))) (alert msg) (princ) ) ;; ArcSine - Lee Mac ;; Args: -1 <= x <= 1 (defun asin ( x ) (if (<= -1.0 x 1.0) (atan x (sqrt (- 1.0 (* x x)))) ) ) As for tips on 3D modeling modeling the cylinder with the two holes is a good start exercise. Start by creating a cylinder of dia 48 and height 100. Place its bottom at 0,0,0. Create another cylinder for the holes and make its dia. 12 and height 100 then use rotate3d to rotate it about the x axis by 90°. Use move 0,0,12 to position it. Before subtracting it from the big cylinder use osnap cen to create a centerline for the hole cylinder. It's easier to do this before you do the Boolean subtract. Use another cylinder to make the other hole. If you have any questions, post them here. Good luck! cylinder holes.01.lsp1 point