Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/25/2022 in all areas

  1. A graphical approach to approximate a centerline between two polylines. To play p.s. Do not exaggerate with sharp curves. p.p.s. For AutoCAD 2011 or higher centerPline.LSP
    1 point
  2. Thanks Steven!! That is exactly what I'm after. That's a really quick method. See the delete lines section at the bottom. Would I need to put that in the *error* handler like so? See my take on it below and also my take on using (if ssLines (command-s "_.Erase" ssLines "")) Full error handler. (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) ; Deletes the temporary lines and hatches (if ssLines (command-s "_.Erase" ssLines "")) (if ssHatches (command-s "_.Erase" ssHatches "")) ; Restore the layer states and delete it (layerstate-restore stateName nil nil) (if (layerstate-has stateName) (progn (layerstate-delete stateName nil nil) ; (layerstate-save stateName nil nil) ) ) Edit 1: There's an error with this msg: ; error: bad argument type: listp <Selection set: 15b> But I'll figure that out. Edit 2: Culprit below (I fixed this by removing this and used the command-s method I have below in the error handler.) (setq ss (reverse ss)) ;; reverses the selection set so item 0 is the first line you drew, item n is the last
    1 point
  3. Just playing with this, happier with this for you: (defun c:trythis ( / MyPoint ss Myloop) ;;; errortrap here if you want to to reset 'osmode to what ;;; it was and to delete the lines you add ;;; also add a start undo mark here, press undo will remove ;;; the lines you have added ;;; You might have these already and they aren't necessary (setq osmodeold (getvar 'osmode)) ;;record existing snap settings (setvar 'osmode 3) ;;set snaps to what you want (setq ss (ssadd)) ;;create empty selection set (setq Myloop "loop") ;;marker to whether to loop again or end the loop (while (= "loop" Myloop ) ;;Loop if loop marker says 'loop' (setq MyPoint (getpoint "\nDraw Line, [Space or Enter to end]: ")) (if (= MyPoint nil) (setq Myloop "StopLoop") ;; if no point is selected (enter or spae pressed) (progn ;;else do this loop (Command "._Line" MyPoint pause "") (setq MyPoint nil) ;;might not be needed, but why not have this (setq ss (ssadd (entlast) ss)) ;;add line to selection set (as item 0, the previous line is line 1, etc) ) ) ) ;end while (setq ss (reverse ss)) ;; reverses the selection set so item 0 is the first line you drew, item n is the last ;;; Do your stuff ;;; ;;delete lines (repeat (setq i (sslength ss)) ;;From https://www.cadtutor.net/forum/topic/73504-deleting-a-selection-set/ (entdel (ssname ss (setq i (1- i)))) ;;delete the last item in the selection set, loop till length of selection set is 0 ) (setvar 'osmode osmodeold) ;;reset snaps (princ "Done")(princ) ;;report 'done' ) tried to add comments how it works Changed around the line creation so that if you don't select a start point it ends, then uses that start point in the normal command so you can see the line you are drawing... I prefer to see the line as I am drawing them as opposed to just selecting points blindly.
    1 point
  4. (while (= (setq sp (getpoimt "\nDraw Line to close up spaces or divide them - Start Point: ")) (setq ep (getpoimt "\nNext Point (enter to skip): ")) ) (Command "._Line" sp ep "") (setq ssLines (ssadd (entlast) ssLines)) ) I think the more natural way is no keyword at all, just let user pick point pick point to draw line until he/she skip one pick point request. To have "Y" or "N" keywords, look at getkword and initget function, quite basic ones.
    1 point
  5. "(defun get_objects_in_viewport (viewport /) ..." is to deal with the given viewport It helps you to move the loop through all viewports routine out to the main routine. But why still in that (defun get_objects_in_viewport (viewport /) you have code to select all viewport and repeat sslength?
    1 point
  6. Please give it a test , maybe some defun is miss, it only work for "AcDbAlignedDimension" Feel free to add error handling or what else ...... ;************************************************************ ;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA ;;; Copyleft 1995-2022 by Gabriel Calos De Vit ; DEVITG@GMAIL.COM ;; ; ---------------------------------------------------------------------- ; DISCLAIMER: Gabriel Calos De Vit Disclaims any and all liability for any damages ; arising out of the use or operation, or inability to use the software. ; FURTHERMORE, User agrees to hold Gabriel Calos De Vit harmless from such claims. ; Gabriel Calos De Vit makes no warranty, either expressed or implied, as to the ; fitness of this product for a particular purpose. All materials are ; to be considered ‘as-is’, and use of this software should be ; considered as AT YOUR OWN RISK. ; ---------------------------------------------------------------------- ;;************************************************************ ;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* (DEFUN &-TEXT/STR-PT-HEI (STR PT HEIG) ;_ 01 (IF (= (TYPE PT) 'LIST) (SETQ P1 (VLAX-3D-POINT PT)) (SETQ P1 PT) ) (VLA-ADDTEXT MODEL STR P1 HEIG) ) ;;;;-******************************************************************************************************************************* ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* (DEFUN G-MIDPOINT/P1-P2 (P1 P2) ;_01 (MAPCAR '* '(0.5 0.5 0.5) (MAPCAR '+ P1 P2)) ) ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* (DEFUN VAR->LST (VARIANT#) ;_01 (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE VARIANT#)) ) ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* ;;;arrange-dim-text-position ;;;*************************************************************;;; ;;;https://www.cadtutor.net/forum/topic/74346-how-to-change-distance-from-dimension-line-to-objects/ (defun arrange-dim-text-position (/ ACAD-OBJ acRed ADOC DESIRED-DIST DIM-ENT-SS DIM-OBJ-SS EXTLINE1POINT-VAR EXTLINE1POINT-XYZ EXTLINE2POINT-VAR EXTLINE2POINT-XYZ MID-PT1-PT2 MODEL NEW-TEXTPOSITION-XYZ NO-WAY TEXTPOSITION-ANGLE TEXTPOSITION-OBJ TEXTPOSITION-VAR TEXTPOSITION-XYZ ) ;_ / (VL-LOAD-COM) (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ el programa ACAD (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ el DWG que esta abierto- (SETQ MODEL (VLA-GET-MODELSPACE ADOC)) (initget 7) (if (not (setq desired-dist (getreal "distance from side")) ) ;_ not (setq desired-dist 15.0) ) ;_ if (setq dim-ent-ss (ssget "_X" '((0 . "dim*")))) (setq dim-obj-ss (VLA-GET-ACTIVESELECTIONSET adoc)) ;;; (setq DIM-OBJ (vla-Item dim-obj-ss 0)) (vlax-for dim-obj dim-obj-ss (if(= (vla-get-ObjectName dim-obj) "AcDbAlignedDimension") (progn (setq ExtLine1Point-var (VLA-GET-ExtLine1Point dim-obj)) (setq ExtLine1Point-xyz (VAR->LST ExtLine1Point-var)) (setq ExtLine2Point-var (VLA-GET-ExtLine2Point dim-obj)) (setq ExtLine2Point-xyz (VAR->LST ExtLine2Point-var)) (setq mid-pt1-pt2 (G-MIDPOINT/P1-P2 ExtLine2Point-xyz ExtLine1Point-xyz)) (setq TextPosition-var (vla-get-TextPosition dim-obj)) (setq TextPosition-xyz (VAR->LST TextPosition-var)) (setq TextPosition-angle (angle mid-pt1-pt2 TextPosition-xyz)) (setq new-TextPosition-xyz (polar mid-pt1-pt2 TextPosition-angle desired-dist)) (vla-put-TextPosition dim-obj (VLAX-3D-POINT new-TextPosition-xyz)) );end progn (progn ;for no way to move (setq TextPosition-obj (vla-get-TextPosition dim-obj)) (setq no-way ( &-TEXT/STR-PT-HEI "NO-way " TextPosition-obj (* 2 (vla-get-TextHeight dim-obj)))) (vla-put-color no-way acred ) );end prog for no way to move );end if ) ;_ vlax-for ) ;end defun (defun c:arr-dim () (arrange-dim-text-position) ) ;;;;;;;|«Visual LISP© Format Options» ;;;(200 2 1 0 nil "end of " 100 20 2 2 nil nil T nil T) ;;;;*** DO NOT add text below the comment! ***|; arrange dim text position cadtutor.lsp arrange dim texts.dwg
    1 point
  7. WoW!!!! thanks @mhupp and @Emmanuel Delay; both lisp works well !!!! @Emmanuel Delay, actually I've want rtab_x and rtab_y It is better for " on site" to be up/down left/right @mhupp You did great Job. It is also numbering rebars. I will try to add to ask user to get firstly number of rebar; like for expample "4" and then it will number it like 4.1, 4.2, 4.3 etc. Also need to add round of the lenght. Guys! You did work for me! actually I thougt I will do this myself just with Your help, but the job is done!!! Thank You so much!
    1 point
  8. It really depends on your own preferences. I like to do the external walls in 0.35, Internal walls, 0.25, Cavities 0.18, Hatching 0.10, Window & Door detail 0.18. However this is on drawings at 1/100 scale. At different scales you will need different settings. I noticed in your drawing you don't have a CTB associated with it. Personally I don't use line weights I prefer to let the CTB file set the line weights when plotting or in a few instances use polylines with set widths. The downside to setting line weights with in the model are that you have to remember to do so every time you change colour. The CTB file has a table of all the pen colours and you can set line width for each colour. There are a set of default CTB's installed with AutoCAD but you can create your own. I would suggest you start of with the one called monochrome.ctb. Also the other thing about CTB files are their ability to control other aspects about the way it plots the drawing i.e. the colour of the line. Monochrome, as the name suggest, plots all the lines in black. At the moment you don't have a CTB associated to your drawing. You can access the CTB files via Page Setup Manager. Remember if you edit one of the standard CTB files make sure you name it with a different name. I only use polylines to set widths where the width is required to be relative to the model i.e. if I want the width to be a constant 100mm relative to the model. If you set a polyline width it will override the CTB file. There is another alternative to CTB which is STB but I don't use them so I'll let somebody else explain them. You can find more information on CTB and STB here http://www.caddmanager.com/CMB/2009/08/cad-standards-ctb-vs-stb/ Hope I haven't bored you to much.
    1 point
×
×
  • Create New...