Leaderboard
Popular Content
Showing content with the highest reputation on 02/29/2024 in all areas
-
Something I was playing around with a while back. I use it form time to time. Made a little update yesterday and thought I'd add it here. Will allow you to select a group of objects and store them for later copying. This objects are stored in a global variable and do not have anything to do with the Clipboard. Once you store the objects, you can continue performing any normal functions and when you are ready to have those stored objects to place somewhere else, just execute the command. Call with Copystored or CS Sorry for the choppy video, I had to cut the frames to keep file size down (not sure what's going on with Camtasia). ;;; ------------------------------------------------------------------------ ;;; CopyStored.lsp v1.3 ;;; ;;; Copyright© 08.18.09 ;;; Alan J. Thompson (alanjt) ;;; ;;; Permission to use, copy, modify, and distribute this software ;;; for any purpose and without fee is hereby granted, provided ;;; that the above copyright notice appears in all copies and ;;; that both that copyright notice and the limited warranty and ;;; restricted rights notice below appear in all supporting ;;; documentation. ;;; ;;; The following program(s) are provided "as is" and with all faults. ;;; Alan J. Thompson DOES NOT warrant that the operation of the program(s) ;;; will be uninterrupted and/or error free. ;;; ;;; Allows user to select object(s) for copying (uses first object in ;;; selection for insertion point or specified point) and stores ;;; selection set and insertion point for later usage. ;;; ;;; Express Tools "acet-ss-drag-move" subroutine required. ;;; ;;; Revision History: ;;; ;;; v1.1 (09.29.09) 1. Changed copy method. ;;; 2. Updated error handler ;;; 3. Added AT:SS->List subroutine. ;;; ;;; v1.2 (12.15.09) 1. Updated to account for non WCS (oversite). ;;; ;;; v1.3 (02.23.10) 1. Added check if "acet-ss-drag-move" is loaded. ;;; 2. Added option to specify copy base point. ;;; ;;; ------------------------------------------------------------------------ CopyStored.lsp1 point
-
The calculation of the length along a polyline is very straightforward. For arc sections the distance along the arc is simply the radius of the arc times the angle subtended by the arc (in radians). Straight line sections, of course, are simply: Distance from point 1 to point 2 = square root ((x2-x1)^2 + (y2-y1)^2 +(z2-z1)^2) Things become a little more tricky with splines. The general spline in AutoCAD is known as a NURBS or non-uniform rational B-spline. NURBS, and its simpler special case forms named B-splines and Bezier splines are parametric functions. For parametric equations an independent variable,, the parameter (u), is used to specify a point on the curve. Give the equation for a spline a value for the parameter u and you'll get back the X,Y,Z coordinates of a point on the spline. This calculation is done quickly and efficiently. However, the calculation of distance along a spline is more complex. It requires mathematics known as numerical integration. Numerical calculations use a trial-and-error like approach to solving a problem. Repeated calculations are made and evaluated to determine the distance along the spline. In making these calculations the parameter u is repeatedly adjusted until the distance along the curve is within some acceptable tolerance. Bottom line? Locating a point on a spline with a parameter is much more efficient than locating a point on a spline given a distance. For example, the calculation for determining the intersection of two splines would manipulate values of u for the two splines on a trial and error basis until a value for each u yielded the same point in space within an acceptable tolerance. In this example, the distance along the curve is not needed. Yes, you can think of the "param" in getPointAtParamas for each segment as a percentage but be careful that for spline the parameter value cannot be directly converted to a distance along the spline since the parameter typically would not vary equally with distance. A nice attribute of parametric splines is that for evenly distributed values of the parameter you will get more points in areas of sharp curvature and in areas of flatter curvature. A simple demonstration of this feature can be shown with a polyline-spline and the splineegs command. In the image below the red line was copied and then using pedit-spline turned iinto a spline. The default value for splinesegs his 8. To draw the spline AutoCAD uses values of 0.0, 0.125, 0.25, 0.375, …, 1.0 for u to determine the chords to draw to represent the spline. Looking closely at the white curve you will see that it's composed of eight straight sections note how they are shorter where the curvature is smaller. If splinesegs is changed to 4, and the spline is decurved and then then splined again the result is as follows. Four chords are used to represent the spline and it looks very crude. If splinesegs is changed to 4, and the spline is decurved and then then splined again the result is as follows. Four chords are used to represent the spline and it looks very crude. On a completely separate but related note, last year I posted this 3ds Max Tutorial on using numerical methods to animate the boom of a trolley conected to an overhead cable. Even if you are not a 3ds Max user or familiar with Max scripts I think you can see how the function interpcurve3d at 6:23 in the video is used to find a point on a curve using a parameter can be helpful in solving such a problem.1 point
-
You might find my ssget Function Reference of interest - it contains slightly more information than the standard documentation.1 point
-
Curves have an independent parameter, let's call it u. For a polyline consisting of one arc the range for u is 0 to 1. If the polyline has two arcs the range for u would be 0 to 2. If u were between 0 and 1 then the point is on the first arc segment. If u is between 1 and 2 then the point is on the second arc segment. Note that the distance along the arc from say, u = 1.1 to 1.2 would be the same as from 1.2 to 1.3 but not equal to the distance from 2.1 to 2.2 since the second arc may have a different radius and subtended angle. vlax-curve-getPointAtParam is used to work with the paramter (u) while vlax-curve-getPointAtDist is used to work with the distace measured along th curve. Note, for Bezier and B-Splines (AutoCAD splines) the maximum parameter variable is an integer. For NURBS the maximum value could be a real number (that's why they are called "non-uniform").1 point
-
That will be the code for bridge cone which is working: (defun c:slope-line-cone-bridge (/ ent1 ent2 pline i pt1 pt2 pt3 dist sset1 ent2 sd slo new_ent new_ent2 elev len1 len2 n_bat point intersection all_entities newpoints ticks curlayer) (command "undo" "m") (setq curlayer (getvar "clayer")) (if(not(tblsearch "LAYER" "9 kreskowanie")) (command "-layer" "new" "9 kreskowanie" "Color" 254 "9 kreskowanie" "LTYPE" "Continuous" "9 kreskowanie" "") );end if (setvar "clayer" "9 kreskowanie") (setvar "celtype" "bylayer") (setvar "cecolor" "bylayer") (setq point (getpoint "\n Select cone center point (top): ")) (setq ent1 (car (entsel "\n Select a TOP polyline: "))) (setq ent2 (car (entsel "\n Select a BOTTOM polyline: "))) (setq n_bat (getint "\n How many batter tics - slope lines: ")) (setq i 0) (setq len1 (vlax-curve-getdistatparam ent1 (vlax-curve-getendparam ent1))) ;(princ "\n") ;(princ len1) (setq len2 (vlax-curve-getdistatparam ent2 (vlax-curve-getendparam ent2))) ;(princ "\n") ;(princ len2) ;(princ "\n") ;(princ n_bat) ;(princ "\n") ;(princ (/ 1 (float n_bat))) (setq all_entities (ssadd)) ; Initialize the list of entities (setq ticks (ssadd)) ; Initialize the list of all entities (setq newpoints nil) ; Initialize the list of intersection points (repeat (+ n_bat 1) (setq pt1 (vlax-curve-getPointAtDist ent1 (* len1 (* i (/ 1 (float n_bat)))))) ; get the point at each len of polyline ;(princ "\n") ;(princ pt1) (setq pt2 (vlax-curve-getPointAtDist ent2 (* len2 (* i (/ 1 (float n_bat)))))) ; get the point at each len of polyline ;(princ "\n") ;(princ pt2) (entmake (list (cons 0 "LINE") (cons 10 point) (cons 11 pt2) ) ) ;entmake end ;(princ "\n created center to end line") (ssadd (entlast) all_entities) (setq intersection (vla-IntersectWith (vlax-ename->vla-object ent1) (vlax-ename->vla-object (entlast)) acExtendThisEntity)) ;(princ "\n intersection found") (setq intersection (vlax-safearray->list (vlax-variant-value intersection))) ;(princ "\n") ;(princ intersection) ;(princ "\n") (if (equal (/ i 2.0) (fix (/ i 2.0)) 0.001) ;check for every second (progn (setq pt2 (polar intersection (angle intersection pt2) (/ (distance intersection pt2) 2))) ;(princ "\n new point py2") ;(princ pt2) );end progn );end if (entmake (list (cons 0 "LINE") (cons 10 intersection) (cons 11 pt2) ) ) ;entmake end (ssadd (entlast) ticks) (setq i (+ i 1)) ) ; Delete all entities created in the loop ; (princ "\n now trying to delete") (sssetfirst nil all_entities) ; (princ "\n now trying to delete") (if all_entities (command "_.Erase" all_entities "")) ; (princ "\n after delete") (COMMAND "-Group" "create" "*" "" ticks "") ;;create group (setvar "clayer" curlayer) );end_defun Thanks everybody for help1 point
-
1 point
-
ah i thought always if thickness 0.75 dont delete. Try this: (defun c:deleteCirclesByDiameter (/ ss diaexception) (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (setq diaexception '(0.6875 0.6880)) (if (not ss) (progn (prompt "\nNo circles found in the drawing.") (exit))) (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (setq dia (* 2 (cdr (assoc 40 (entget ent))))) (if (and (> x f) (> x dia) (not (and (member dia diaexception) (= x 0.75))) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (prompt (strcat "\nSkipped Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (setq index (1+ index)) ) (prompt "\nCircles with diameter less than x have been deleted.") )1 point
-
this is basically the same function as yours but with most of the progns removed. but the other problems i said are still here: double entdel -> does nothing if 'then' and 'else' expression are the same using 'x' within the if function but that gets set nowhere (defun c:deleteCirclesByDiameter (/ ss) (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles found in the drawing.") (exit))) (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (setq dia (* 2 (cdr (assoc 40 (entget ent))))) (prompt (strcat "\nCircle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (entdel ent) (if (and (> x f) (< dia x)) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (setq index (1+ index)) ) (prompt "\nCircles with diameter less than x have been deleted.") (princ) )1 point
-
SRTCASE converts lowercase letters to uppercase. In principle, it would not be necessary to use it.1 point
-
(setq pos1 (vl-string-search "+" input-string))) (setq pos2 (vl-string-search "+" input-string (+ pos1 1))) (setq pos3 (vl-string-search "/" input-string)) (setq pos1a (1+ pos1)) (setq pos2a (1+ pos2)) (setq pos3a (1+ pos3)) (setq cad1 (strcase (substr input-string (1+ pos1a) (1- (- pos2a pos1a)))));return "PL3/18" (setq cad2 (strcase (substr input-string (1+ pos2a))));return "A36"1 point
-
There was a post about using handle ID and that it increases in value so I have not used it but would be interesting to try, need to convert hex to a number. A list sorted ((num Entity name: 2f9f3670>)...... I tried this as a test seemed to work. ; reorder a selection set using Handle for order ; by AlanH 29 Feb ;; Base to Decimal - Lee Mac ;; Converts an number in an arbitrary base to decimal. ;; n - [str] string representing number to convert ;; b - [int] base of input string ;; Returns: [int] Decimal representation of supplied number (defun LM:base->dec ( n b / l ) (if (= 1 (setq l (strlen n))) (- (ascii n) (if (< (ascii n) 65) 48 55)) (+ (* b (LM:base->dec (substr n 1 (1- l)) b)) (LM:base->dec (substr n l) b)) ) ) (defun LWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst))) ) (defun c:wow ( / ) (prompt "pick objects ") (setq ss (ssget)) (setq lst '()) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (1- x))))) (setq id (cdr (assoc 5 ent))) (setq enty (cdr (assoc -1 ent))) (setq num (LM:base->dec id 16)) (setq lst (cons (list num enty) lst)) (princ) ) (setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y))))) (setq lst2 '()) (foreach val lst (setq ent (cadr val)) (setq lst2 (cons (cdr (assoc 10 (entget ent))) lst2)) ) (lwpoly lst2 1) (princ) ) (c:wow)1 point
-
There was a make formula lisp somewhere that looks for the math operator + - / * etc, try googling.1 point
-
@zwonko The function vlax-curve-getPointAtParam does not increase linearly with respect to distance if the curve does not have a constant radius. SInce your polyline has more than one arc segment and they are of different radii you should not be computng the interval in parametric space. Use vlax-curve-getPointAtDist instead.1 point
-
I was working on this same issue recently. As far as I can tell, there is no way to apply vertical exaggeration to labels. So Sinc's observation from 2012 is still valid. My ultimate solution was to create an expression and hard-code the scale into it.1 point
-
1 point
-
Does the string alway have the same format? xyx '+' PL12/34 '+' A12 Where there is a '+' to separate the portions of the text? My favourite way to separate strings like this is to use Lee Macs String to List LISP and here, use + as the separator which will return a list like this (112 PL3/18 A36) containing 3 list items Use nth or car, cadr, caddr to extract the text strings. This works really well if the text is all in the same format and you want to get the same part of the text string, a bit trickier if there is no constant separator or if there are a different number of string segments in it1 point
-
@ajithkumar.t I do not understand your question. Please provide a sample drawing with a before and after of what you would like to do.1 point
-
Take a look at this series of functions for editing attribute properties. You can probably adapt one of them to edit text properties by changing the loop test. Here's another function that (I think) does a global style change, even inside blocks. With a little tweaking, it should do the same for all the other properties you want to change. If these don't help, please provide more information about your goals. Welcome to the forums!1 point
-
1 point