Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Thanks MHUPP - that was a thought I'd add for the OP tomorrow, can copy and paste from here rather than try to remember where I last used last ent.
  3. Change elevation only works if all points are on the same Z elevation. this might be why also flatten isn't working for you. Two things you can do to speed up. Combine all the commands into one call like you did below Command has some type of "lag" if its 100ms that goes from 600ms to 100ms and if your looping everything in the drawing That will be multiplied. if you sent LastEnt anything created or modified after is "behind" LastEnt in the drawing and can be added to a selection set with a simple loop. rather then selecting everything in the drawing and checking if its a member of the before selection set. (setq zList '()) ;(setq before (ssget "_X")) ;not needed anymore (command "regen" "_.copy" obj "" '(0 0 0) '(0 0 0)) (setq LastEnt (entlast)) ;set right before you create/modify objects. you want to either add to a selection (command "_.explode" newent) (while (setq LastEnt (entnext LastEnt)) ;after entities are created this will add them to a selection set. (ssadd EntLst newents) ) (foreach e newents
  4. Just to amuse myself, here is a snippet that will flatten simple entities, not sure if that helps you along the way - you can use what code works for 3d polylines, hatches, regions and blocks - might be a bit quicker Command: NewFlatten (defun FlattenLines ( / MySS MyEnt acount ed) ;;Does lines, circles, arcs, ellipses, texts, LWPolylines (setq MySS (ssget "_X" (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "<>") (cons 38 0) '(-4 . "OR>") ))) ; end list, ssget, setq (setq acount 0) (while (< acount (sslength MySS)) (setq MyEnt (ssname MySS acount)) (setq ed (entget MyEnt)) (if (equal (assoc 0 ed) (cons 0 "LWPOLYLINE")) (progn (entmod (setq ed (subst (cons 38 0) (assoc 38 ed) ed) )) ;; Elevation to 0 ) ; end progn (progn (entmod (setq ed (subst (cons 10 (mapcar '* '(1 1 0) (cdr (assoc 10 ed)))) (assoc 10 ed) ed)) ) (entmod (setq ed (subst (cons 11 (mapcar '* '(1 1 0) (cdr (assoc 11 ed)))) (assoc 11 ed) ed)) ) ) ; end progn ) ; end if (setq acount (+ acount 1)) ) ; end while ) (defun c:NewFlatten ( / ) (FlattenLines) ;; flatten simple entities ) ; end defun
  5. Today
  6. Depends what you are using for obj, if it is an entity name this is a bit quicker: (command "_.copy") (command obj) (command "") (command '(0 0 0) '(0 0 0)) (setq newent (entlast)) (command "_.explode" newent) becomes (command "_.Explode" (setq NewEnt (entmakex (entget obj)) ) ) where obj might be from (car (entsel)) or (ssname MySS number) Might want to look at the number of loops in the snippet you posted
  7. I trid Change > elevation > 0 but not working. I can't share the full code, but for REGION entities, I'm currently using a method that copies and explodes them to get the Z values, then moves the original REGION to Z=0. I know it's not efficient, but it works. ((equal entType "REGION") (vl-catch-all-apply (function (lambda () (setq zList '()) (setq before (ssget "_X")) (command "regen") (command "_.copy") (command obj) (command "") (command '(0 0 0) '(0 0 0)) (setq newent (entlast)) (command "_.explode" newent) (setq after (ssget "_X")) (setq newents '()) (setq j 0) (while (< j (sslength after)) (setq ent (ssname after j)) (if (not (ssmemb ent before)) (setq newents (cons ent newents)) ) (setq j (1+ j)) ) (foreach e newents (setq entdata (entget e)) (cond ((= (cdr (assoc 0 entdata)) "LINE") (setq z1 (nth 2 (cdr (assoc 10 entdata)))) (setq z2 (nth 2 (cdr (assoc 11 entdata)))) (setq zList (cons z1 zList)) (setq zList (cons z2 zList)) ) ((member (cdr (assoc 0 entdata)) '("ARC" "CIRCLE" "ELLIPSE") ) (setq z1 (nth 2 (cdr (assoc 10 entdata)))) (setq zList (cons z1 zList)) ) ) ) (setq ztotal 0) (if (< 0 (length zList)) (progn (foreach z zList (setq ztotal (+ ztotal z))) (setq zmid (/ ztotal (length zList))) (command "_.MOVE" obj "" '(0 0 0) (list 0.0 0.0 (* zmid -1)) ) ) ) (foreach e newents (entdel e)) ) ) ) ) And also is there a way to use ssget to select only entities that have non-zero Z values?
  8. That would get most of the simpler entities such as lines, text, circles and so on. LWPolylines you can add another "or": '(-4 . "<>") (cons 38 0.0) and so on building up the selection set filter that way: (ssget (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "<>") (cons 38 0) '(-4 . "OR>") )) For 3d polylines, for example, so long as the first point (first dxf code 10 in the entity description) isn't at zero elevation it should also grab them too. However if this only removes lines, LWPolylines, circles, arcs, texts, ellipses... it should reduce the amount of processing. Depends how you are doing it but the blocks might be your slow point.
  9. Can't really tell you how to optimize code you didn't post, but when people first get into lisp the rely heavily on command because its follows what you would type into the command line. It become apparent in a loop processing 1000's of entity's that its quite inefficient. rather then using entmod or some other way to update model. If flatten doesn' work also try the command Change > elevation > 0
  10. yes flatten is not working sometimes block, pline, dimension. So ı need this lisp. this lips so limited. for exaple there are multiple 10 dxf data in POLYLINE. I need something more comprehensive
  11. I guess the flatten command has some limitations for you (I've never been 100% with trusting flatten)
  12. Here is a quick example, (ssget (list '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "OR>") )) Should select the more simple entities not at 0 elevation - not sure it will work for 3d polylines for example, but should be OK for lines, circles, arcs and so on and apply similar to others?
  13. Hi everyone, I'm working with a large AutoLISP routine that sets the Z elevation of all objects to 0 — similar to a custom Z0 command. It handles a wide range of entity types including: LINEs, ARCs, CIRCLEs, POLYLINEs (both 2D and 3D), LWPOLYLINEs, SPLINEs, HATCHes, TEXT, MTEXT, DIMENSIONs, INSERTs (blocks), including nested block content, and REGION entities. What it does: For each entity, I check its Z elevation and flatten it: For regular entities, I modify their coordinate group codes (10, 11, etc.) using entmod, or use vla-put-elevation where applicable. For INSERTs, I dive into their nested entities and apply the same logic. For REGIONs, I currently copy and explode them temporarily, analyze the resulting geometry to determine the average Z, then move the original REGION to Z=0. My problem: The command works fine, but performance is a major issue, especially on complex or large drawings. What are the best ways to optimize performance for a routine like this? Is there a better way to flatten REGIONs without exploding them? Specifically, is there a way (maybe via a filter or a helper LISP) to select only entities whose Z coordinate is not zero? That would allow me to skip processing objects that are already flat and significantly improve performance. Thanks a lot in advance for any suggestions!
  14. thanks @SLW210.
  15. Yesterday
  16. BIGAL

    CUI Input Text Field?

    if you want a radio button pick have a look at my Multi radio buttons.lsp it can hold about 20 values vertically. once you pick I use Ldata to save the value in a dwg, in the multi R you can set the button to the current value. In a pop menu would be just a load a lisp as normal all the values being in it that lisp.
  17. BIGAL

    Structural drafting tools

    @masterfal one of the answers you are looking for is Strucplus, it is an Aus product just like me. Its been around for like 40 years has lots of good steel connection drafting tools. I have a manual & code but its back in that era and I am sure it has been improved over time, has concrete as well. I have some concrete slab on ground stuff. Draw beams, Waffle slabs, etc. Did some stuff at one stage for tilt panels. I used to have choose concrete beam types and matching blocks, these were chosen via pop image menu's. As suggested there is a lot of stuff out there just have to find it. Did you google "reinforced concrete beams Autocad lisp". Send me a PM with your email and can talk more Aussie time. I am near Newcastle.
  18. Saxlle

    CUI Input Text Field?

    Hi @CivilTechSource, Here is the an example how you can do it on different approach. In AutoCAD exist "blackboard", where you can store the desired value where you can than use that value in the other open drawings (more about blackboard: About Sharing Data Between Namespaces (AutoLISP)). In this example, I have a "text size values.txt" file with different heights. It can be update with other height values. 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 So, after run this function, you will first choose the file with values (in this case "text size values.txt"), than pick the desired value and add it to blackboard. (prompt "\nCall function: (getValueFromListBlackboard)") (princ) ;; Add any value from list to the "blackboard" (defun getValueFromListBlackboard ( / *dcl_id* *file_name* *op* *lst* *textSize* *path* *file* *line* *rval*) (setq *path* (getfiled "Open the txt file with list of values"" "txt" 0) *file* (open *path* "r") ) (if *file* (progn (while (setq *line* (read-line *file*)) (setq *lst* (append *lst* (list *line*))) ) (close *file*) ) ) (setq *file_name* (vl-filename-mktemp "textHeight.dcl") *op* (open *file_name* "w") ) (write-line "textHeight :dialog { label = \"Select Text Heights\"; :list_box { key = \"tx\"; multiple_select = true; height = 20; width = 30; } :row { :button { label = \"Pick text height\"; key = \"bth\"; fixed_width = true; } :button { label = \"Cancel\"; key = \"cancel\"; mnemonic = \"C\"; alignment = centered; fixed_width = true; is_cancel=true; } } }" *op*) (close *op*) (setq *dcl_id* (load_dialog *file_name*)) (if (not (new_dialog "textHeight" *dcl_id*)) (exit) ) (action_tile "cancel" "(done_dialog 0)") (start_list "tx") (mapcar 'add_list *lst*) (end_list) (defun return_value () (setq *rval* (nth (atoi (get_tile "tx")) *lst*)) ) (action_tile "bth" "(return_value) (done_dialog 1)") (start_dialog) (unload_dialog *dcl_id*) (vl-file-delete *file_name*) (vl-bb-set '*textSize* *rval*) (vl-bb-ref '*textSize*) ) After you pick the desire height, you can change it in all open drawings for any text. In this case, I made a little lisp for that and I need it to call every time in different drawing (except if you don't want to make it in support file search path or to be autoloaded every time when AutoCAD is started). (defun c:CTH ( / data) (setq data (entget (car (entsel "\nSelect the text:")))) (entmod (subst (cons 40 (atof (vl-bb-ref '*textSize*))) (assoc 40 data) data)) ) An example video of how it works you can see below. ChangeTextWithValueFromBlackboard.mp4 Maybe in this you can get some idea how to make it work in your case. Also, you can add "getValueFromListBlackboard" to CUI and make it easier to call. Best regards.
  19. I had partially worked out at one time, at least enough to get the vertices, with Owen Wengerd’s acis-decode function for lisp. Just filter ("point" "$-1" "-1" "$-1" "100" "100" "0" "#") -> ("point" "100" "100" "0") -> -(100.0 100.0 0.0) Ideally, it would be better to filter out the edges, so you know what point connects to what. I think each $INT represents a line number example, the first face points to the next face on line 6...
  20. Thanks Daniel, that does look like a convenient way to do it. I don't know how to use the ARX stuff though, never got into that. Too bad there isn't a AssocPersSubentIdPE function in lisp!
  21. CivilTechSource

    Structural drafting tools

    Have you tried checking the AutoDesk App store? I do recall seeing a rebar drafting plugin.
  22. Hi All, I currently do structural drafting (mainly residential) and have been doing that for quite a number of years now and in that time i have noticed that there are not a great deal of tools available - built into autocad or otherwise. they have stuff for mechanical, architectural, electrical, plumbing etc but doesn't seem to be much for structural. would be cool if there was stuff to help with drawing footings or reinforcement in slabs or stuff to help with detailing. Anyway i was just wondering if anyone had anything specifically useful for structural drafting that they use that they would be happy to share? Something i use all the time is this steel lisp routine (attached) which includes all the common steel member sizes used in australia which you can add in cross section view, top view or side view. Would be good if could add t-bars in there somehow too. had little look but couldn't work out exactly how to do it. i can edit the shapes that are currently in place but not sure how to add in new shapes and sizes.. edit - with this stl routine it was originally set up to also load a US version of the member sizes but i've tweaked it so STL only opens the aus version as i have no need for US sizes. i think the info for the US sizes are still there so if you want those you will need to amend the routine slightly Stl.zip
  23. Last week
  24. BIGAL

    LISP Command names and shortcuts

    You dont need to load all the lisps, if you use say a custom lisp and auto load it, inside you have all your Le lisps set via AUTOLOAD so when you type the command it loads the correct lisp. I have like 15 of them. Type "zzz" etc (autoload "COPY0" '("COPY0")) (autoload "COPYCOMMAND" '("ZZZ")) (autoload "COVER" '("COVER")) (autoload "DIMFLIP" '("DIMFLIP")) (autoload "DRAWXFALL" '("DRAWXFALL")) (autoload "DRAWPIPE" '("DRAWPIPE"))
  25. Can the code not depend on the values of "LISPSYS" (0, 1, 2)?
  26. Not in my experience, but it's possible.
  27. That's a point - forget what I said.
  28. But after changing LISPSYS, the code only worked after restarting Autocad... So it's impossible to configure it in the code?
  29. If you want you can do something like (setq LispSys_Old (getvar 'lispsys)) (setvar 'lispsys 0) ... do your code here (setvar 'lispsys LispSys_Old) to set it and reset it to what it was if you are worried about the change affecting other things. I would normally set a variable and return it to what it was with the least code in between in case the LISP is interrupted or to put in error handling to return it to its original value
  1. Load more activity
×
×
  • Create New...