Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. BIGAL

    Dynamic variables

    There may be ways to speed up using a list of 20,000 points, the first is if your points are numbered then make the list that way you have to but pt number 0 as 1st item then a (nth x lst) is a simple task and does not need the (- x 1). Re find a point depending how the list is made there is a way of quickly finding the point based on a sorted list a 10,000 list takes 13 tries to find the correct answer, it uses a 1/2 algorithm, look at 5000 item is it before or after look at say 2500 is it before or after so very fast. Can you explain what it is your doing and maybe some people here can provide faster code. I know something I did took 34 minutes 1st go, it now takes 2 minutes including user input.
  3. Today
  4. PGia

    Dynamic variables

    @mhupp: in principle, my goal is to make a comparison between processing speed when the information to be looked up is stored in a very large list versus when it is stored in variables. I suppose that, as Lee or Pkenewell say, it is risky. But I think that if atoms-family allows complete control of AutoCAD's symbol table, it is worth trying to test this coding method.
  5. PGia

    Dynamic variables

    Thank you very much, @pkenewell I will try to make use of your code in my experiments. However, I'm not sure whether I should consider my question answered: can AutoCAD's internal symbol table really be controlled from atoms-family? Or is it possible that any symbol created during an AutoCAD session survives for as long as the session lasts, even if its value is nil? I apologize if my question seems awkward or absurd, but I would really like someone to give me a clear answer about this.
  6. yes, good idea.
  7. mhupp

    Dynamic variables

    I Agree with Lee I'm interested in what your actually doing. take this for example. different approaches lisps that have a large range of run times. all basically doing the same thing. mine still took over a min to run, but ronjonp came in with 4.07 sec. theirs built an main list processed that list into smaller lists. once processed removed the items from each lists. (speeds up search)
  8. SLW210

    Selecting viewport in a lisp

    Here is my latest zoom .9x in all layouts. I hadn't noticed the OP posted a .dwg, so i ran my Viewport Border into Model code on it. Is the result you wanted? ====================================== AutoVPBrdr REPORT ====================================== True layout viewports: 4 Viewport layer assignments: 4 Layer assignment failures: 0 Modelspace borders created: 3 Viewports skipped: 1 -------------------------------------- Layer: Viewport Color: 45 Plot: OFF ====================================== ZE_Z9XP_1.1.lsp
  9. pkenewell

    Dynamic variables

    @PGia While it's very possible to create variables on the fly. I agree with Lee that it should not be a method to use, especially in the way you are wanting to use it. That being said, I wrote the following many years ago, but hardly have ever used it for anything. It accepts an assoc. list of strings representing variables and the corresponding values, then creates a variable for each with the value. The core of it is very simple (set (read "StrVar") value) ;|============================================================================== Function Name: (pjk-dynsetvar) Arguments: assoclst = List of cons; an assoc list on the format: (list (cons "<var name1>" <value1>) ... (cons "<Var namN>" <valueN>)) Usage: (pjk-dynsetvar <Assoc. List>) Ex: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) Returns: The results of the read list. You can verify the variables with the ! prefix: Command line Example: Command: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) ((1.0 1.0 0.0) 0.25) Command: !Cenpt (1.0 1.0 0.0) Command: !Radius 0.25 Description: This function dynamically sets AutoLISP variables based on an association list of strings and values. The string keys represent the names of the variables that the values will be assigned to. ================================================================================|; (defun pjk-DynSetVar (assoclst) (mapcar (function (lambda (x)(set (read (car x)) (cdr x)))) assoclst) ) ;; End Function (pjk-dynsetvar)
  10. SLW210

    Center mark replacement

    It seems it's not placing CENTERMARKS in Mechanical, I haven't tested other verticals from the toolset, it does use my fallback CrossHairs, though. I may not bother getting CENTERMARK to work in verticals unless someone else is interested, I would use the LISP in AutoCAD anyway, but I will do some testing on Mechanical/Architectural drawings in AutoCAD when I have time. Speaking of time, does anyone have a LISP or something that can give me a 30+ hour day, maybe @rlx I'll try to check this latest version in AutoCAD 2000i this weekend.
  11. For most parts to be manufactured, fully dimensioning the 2D drawing would show any errors, I have never worked anywhere that manufactured from the 3D model, always needed a 2D drawing fully dimensioned. Though, I suppose for arguments sake, possibly could just make a model, create the 2D profiles and send them to a waterjet/plasma cutter, in that instance I would dimension relevant places/points and remove the dimensions before sending the profile, though in reality, I always create a fully dimensioned 2D anyway and I have sent the waterjet programmer the dimensioned profile if requested, it can be made a non-path object or deleted there. I rarely need specific dimensions on my 3D prints, though I draw them to a specific size usually, the ones that need mating parts I do same as you, but then again, creating 2D profiles, sections etc. can be of great help.
  12. A 3D model can look correct from every viewing angle, but small geometric errors may only become noticeable when preparing manufacturing drawings. For critical parts, I check important dimensions, inspect the model from different directions, and compare key cross-sections against the design requirements. I also avoid relying only on shaded views because they can hide small gaps, incorrect alignments, or geometric deviations. What checks do you normally perform before approving a 3D model for manufacturing?
  13. PGia

    Dynamic variables

    Thanks for your answer, @Lee Mac. I've tried creating a list with the coordinates of almost 20,000 objects and managing it on the fly with assoc and subst. However, the processing speed is quite slow. For this reason, it occurred to me to try dynamic variables. You're probably right. But in your answer, you seem to concede a small possibility that using them might actually be worthwhile. What do you mean by that?
  14. Yesterday
  15. Ok this is just a start to show how it could be done. Save the Multi getvals.lsp to a support path as its a library lisp that can be used in any code. Or edit the (load "C:\\fullpath\\multigetvals") Just enter rows and cols as 1 only option started at this stage. ; https://www.cadtutor.net/forum/topic/99378-aluminum-composite-panels-parametric-templates/ : draw panels by AlanH Nov 2026 (defun c:wow ( / ans cols dimoff horizontalonly lay laylst lwt multipanels pt pt1 pt2 pt3 pt4 rows singlepanel verticalonly wid ht top bot left right )Multi GETVALS.lspMulti radio buttons.lsp (defun singlepanel ( / ) (setq ans (AH:getvalsm (list "Enter values " "Width " 5 4 "400" "Height " 5 4 "300" "Top " 5 4 "25" "Bottom " 5 4 "25" "Left" 5 4 "20" "Right" 5 4 "20" ))) (setq wid (atof (nth 0 ans)) ht (atof (nth 1 ans)) top (atof (nth 2 ans)) bot (atof (nth 3 ans)) left (atof (nth 4 ans)) right (atof (nth 5 ans))) (Command "pline" pt "w" lwt "" (polar Pt 0.0 wid) (polar (getvar 'lastpoint) (/ pi 2.) ht) (polar (getvar 'lastpoint) pi wid) "C") (princ) ) (defun verticalonly ( / ) (alert "vertical1only") (princ) ) (defun horizontalonly ( / ) (alert "horizontaly1only") (princ) ) (defun multipanels ( / ) (alert "Multipanels") (princ) ) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already (setq but 1) ; this is needed to set default button for mkulti radios (setq ans (AH:getvalsm (list "Enter values " "Number Hor panels" 5 4 "2" "Number Vertical panels" 5 4 "2" "NAME" 20 19 "" "PCS" 20 19 "PCS"))) (setq cols (atoi (nth 0 ans)) rows (atoi (nth 1 ans)) pname (nth 2 ans) pcs (nth 3 ans)) (setq dimoff 15 lwt 0.7) (setq pt (getpoint "\nPick lower left point ")) (cond ((and (= rows 1)(= cols 1))(singlepanel)) ((and (> rows 1)(= cols 1))(verticalonly)) ((and (= rows 1)(> cols 1))(horizontalonly)) ((and (> rows 1)(> cols 1))(multipanels)) (progn (alert "something is wrong in your rows and columns\nWill exit now. Please redo")(exit)) ) (setq laylst (list '("_F" 4) '("_R" 3) '("_DIM" 32))) (foreach lay laylst (if (tblsearch "layer" (car lay)) (princ lay) (command "-layer" "M" (car lay) "c" (cadr lay) "" "LW" 0.0 "" "") ) ) (princ) ) (c:wow) Let me know what you think about this idea. Multi radio buttons.lsp Multi GETVALS.lsp
  16. @Steven P A couple of suggestions (defun MakeDriveList ( / replace with (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already (setq drivelist (ah:butts 1 "V" '("Please choose" "C:" "D:" "E:" "F:"))) "(setq GetFolderDcl (load_dialog "GetFolder"))" I use the write dcl to lisp by RLX so dcl code can live in the master lisp, then only one file. You may be able to use powershell to dump out the correct drives including network drives to a file and read that with lisp, done via a (startapp c:\path\drives.bat) powershell Get-PSDrive -PSProvider FileSystem | Out-File -FilePath "D:\acadtemp\drives_list.txt" exit Convert dcl 2 lisp rlx.lsp Multi radio buttons.lsp
  17. Frustratingly I think it has a couple of VLAX functions but not all of them - for LT I'd be finding another way if possible (in my example above bypassing the functionality completely)
  18. Lee Mac

    Dynamic variables

    A couple of points to make: The need to create thousands of variables on-the-fly typically points to poor program design; in almost every case, a list is more suitable. Setting all such variables to nil at the end of the program does clear them from the document namespace, but consider that you are essentially creating & clearing global variables that are not local to the scope of your program, and as such, the variable names could potentially clash with identically named variables in the document namespace - this is generally considered bad practice.
  19. Hi again. There's something I can't seem to find a clear answer to. Maybe someone here can give me that answer. I'm experimenting with the use of dynamic variables, created in real-time. However, there's something that often makes me doubt whether it's advisable to use them. And that's where my question lies: If my code creates thousands of variables to avoid having to store data in a structure (lists or arrays)... when at the end of the code I cancel each of those variables with (set 'v nil), do the names of those variables really disappear from AutoCAD's symbol table, or only their content? I know about the atoms-family function and that it returns the value of a symbol if it exists. But the AI says that a negative response from atoms-family is not a guarantee that the symbol no longer exists in AutoCAD's internal symbol table. Thanks in advance.
  20. When modelling symmetrical components, the mirror plane is not always parallel to the standard XY, YZ, or XZ planes. The MIRROR3D command makes this easier by allowing you to define a custom mirror plane using three points. This is useful when creating matching components for angled brackets, machine parts, or other non-standard shapes. After mirroring, I also check the position and orientation of the new solid. Have you used MIRROR3D with a custom plane? What method do you prefer for creating symmetrical 3D parts?
  21. When assembling a 3D model, positioning one component accurately against another can be difficult, especially when both parts are at different angles. Instead of repeatedly using MOVE and ROTATE3D, 3DALIGN can help. By selecting matching points on both objects, you can position and orient one part accurately. I find this useful when assembling mechanical components or placing parts into an existing model. Do you use 3DALIGN for positioning 3D components, or do you prefer to adjust their position manually?
  22. THANKS FOR SHARING!
  23. YES!circular profiles in piping, twisting is usually less noticeable. Thanks for sharing your experience.
  24. Last week
  25. @BIGAL you're correct...in fact functions attempting to access 3rd party apps like Excel are all not supported: https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-037BF4D4-755E-4A5C-8136-80E85CCEDF3E
  26. The other important one missing is Vlax-get-application it allows you to talk to Excel via lisp.
  27. There is auto make layouts, choosing size and scale of viewport, a couple of options like pick a point, enter scale and title block needed, add rectangs for title block in Model at scale and make new layouts, a couple of different methods. Draw rectangs.mp4 Just ask if interested.
  28. @indiancad here's a thread that you might find interesting regarding twist relative to a spline. Note that the first derivative of a curve is a vector tangent to the spline at a specifed point on the spline. The second derivative is a vector thet is the direction and magnitude of the change in the tangent vector at a point. The cross product of these two vetors, also know as the transverse vector, point to the instantaneous center of curvature for the curve at a specfied point along a curve. I wrote the following program to display graphically the radius of curvature (the ends of the generated lines are the center of curvature) or the curvature of a spline (short lines indicate almost flat segments of a spline). Try the program on a spline and answer Yes when prompted. (defun C:DOCL (/ path inc n osm par der1 der2 curva p perp normv p2 sf curveType ans) ; = Degree Of Curvature - Lines ; Creates curvature lines or radius-of-curvature lines ; normal to a spline. ; LRM 8/18/2022 edited to place curvature vectors outside (setq path (car (entsel)) inc (/ (vlax-curve-getEndParam path) 100) n 0 osm (getvar 'osmode) ) (setvar 'osmode 0) (setvar "cmdecho" 0) (initget "y n") (setq ans (getkword "Do you want radius-of-curvature instead of curvature? [y/n] <n>: ")) (if (= ans "y") (setq curveType 1) (setq curveType 2 sf (getdist "Enter scale factor.") ) ) (repeat 100 (setq par (* inc n)) (setq der1 (vlax-curve-getfirstDeriv path par) der2 (vlax-curve-getSecondDeriv path par) ) ; calculate curvature at point par (setq d (distance '(0 0 0) (cross der1 der2))) (if (> (abs d) 1.0e-15) (progn (setq curva (/ (expt (distance '(0 0 0) der1) 3) d)) (if (= curveType 2) (setq curva (* -1. (* sf (/ 1. curva)))) ) (princ "\n") (princ n) (princ " curvature = ") (princ curva) (setq p (vlax-curve-getPointAtParam path par) perp (unitv (cross der1 (cross der2 der1))) normv (mapcar '* perp (list curva curva curva)) p2 (mapcar '+ p normv) ) (command "_.line" p p2 "") ) ; end progn ) (setq n (1+ n)) ) (setvar 'osmode osm) (setvar "cmdecho" 1) (princ) ) ;;; Compute the cross product of 2 vectors a and b (defun cross (a b / crs) (setq crs (list (- (* (nth 1 a) (nth 2 b)) (* (nth 1 b) (nth 2 a)) ) (- (* (nth 0 b) (nth 2 a)) (* (nth 0 a) (nth 2 b)) ) (- (* (nth 0 a) (nth 1 b)) (* (nth 0 b) (nth 1 a)) ) ) ;end list ) ;end setq c ) ;end cross (defun unitV ( v / d) (setq d (distance '(0 0 0) v) d (mapcar '/ v (list d d d)))) blocks_on_spline.lsp spline curvature.lsp
  29. FYI: LT 2024+ does support vlax functions but not vlax-create-object
  1. Load more activity
×
×
  • Create New...