Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/2024 in all areas

  1. @mostafa_mashhadi In simplest terms: (command "._line" pause "_per" pause); draw a line using the "per" (perpendicular) object snap. 1st PAUSE is selected "P1", 2nd PAUSE is the selected point on the line. (setq p2 (getvar "lastpoint")); P2 stores the last point selected, modified to be perpendicular to the line Did you want a more mathematical solution? Please be more specific. - Is the existing line segment just a LINE or a part of a POLYLINE, could it be both? Here is another trick solution I have used which doesn't require that much code: (defun c:foo (/ rp lp1 lp2 a p2 pp sl) (if (and (setq sl (entsel "\nPick a point on the line: ")) (setq rp (cadr sl) lp1 (osnap rp "mid") lp2 (osnap rp "end") a (angle lp1 lp2)) (setq p2 (getpoint "\nSelect Perpendicular source point: ")) ) (progn (setq pp (inters lp1 lp2 p2 (polar p2 (+ a (/ pi 2)) 1.0) nil)) (command "._line" "_non" pp "_non" p2 "") (princ (strcat "\nPerpendicular Coordinate: " (rtos (car pp)) "," (rtos (cadr pp)) "," (rtos (caddr pp)))) ) ) (princ) ) NOTE: the coordinates of the point you want are stored in variable "pp". EDIT - I updated the 1st pick to be a select box for the line for easier selection.
    2 points
  2. Thank you very much. This is exactly what I wanted
    1 point
  3. _regapp is part of the Purge command it removes unneeded regapps (registered applications). Terry Dotson gives a good explanation HERE... Try QNEW manually, it opens a new drawing and changes focus to that drawing.
    1 point
  4. When you get to like 1200 lines of code start looking for code improvements using defuns for repeating patterns of code. You can also make library lisp code and load it as part of your code. An example 100 lines of code, Multi radio buttons.lsp making a radio button DCL, but in your code is only 3 lines. Using Foreach can be used in a loop to say set variables( ("osmode" 0)("Grid" 1)....) a couple of lines v's a line for each setvar. A more advanced task sometimes you don't know how many variables you need eg X1, X2... you can make multiple variables and assign a value. Anyway just ask for help when your stuck good to see your having a go at coding.
    1 point
  5. @mhupp we all do it a typo. Forgot the C:. (defun C:ITN () (c:IncrementTextNumber))
    1 point
  6. Almost forgot you need this also. It asks for you tick on if your table has Title, Header & Data. Just save in a support path so auto loads. Or add full path to (load "Multi toggles.lsp") Multi toggles.lsp
    1 point
  7. Thank you @pkenewell and @ronjonp for the help. Very much a beginner here trying to learn. With your help I was able to cut out about 200 lines of code.
    1 point
  8. This seems to work okay on my machine. ;;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ;;; | ;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Modified to Import DXF (.dxf) to AutoCAD (.dwg)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| ;;; | ;;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ;;; ;;; Original versions I got from here ;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-convert-dgn-to-dwg/td-p/3237978 ;;; ;;;* DGNIMPORT.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings ;;; Start command by typing DGNI ;;; ;;; Make the necessary adjustments to the following variables: ;;; --------------------------------------------------------- ;;; tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported, ;;; names of *.dgn drawings may be written without extension, as well as with extension, ;;; in plain text format, no return after the last line. ;;; tx2 = the path for the input folder, containing the actual *.dgn files to import. ;;; tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved, ;;; (routine assumes that the *.dwg files do not exist yet) ;;; tx4 = name of the drawing model to import ;;; ;;; ;;; The routine reads drawing names from the file given in tx1 line-for-line. ;;; In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing, ;;; does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3, ;;; and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop. ;;; ;;; The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation ;;; between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings). ;;; ;;; The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma, ;;; I advise to rename drawings having this issue. ;;; ;;; Written by M. Moolhuysen. Modified by C. Matthews ;;; ;;; This software may not be sold as commercial product or included as part of a commercial product. ;;; ;;; ;;;*********************************************************************************************************************** ;;;*********************************************************************************************************************** ;;; Converts a folder of DXF *.dxf drawings into AutoCAD® *.dwg drawings * ;;; Start command by typing DXF2DWG * ;;; * ;;; Modified by SLW210 A.K.A. Steve Wilson from DGN import to DXF import 01/10/2024 * ;;; * ;;; * ;;; In response to this thread at CADTutor * ;;; * ;;; https://www.cadtutor.net/forum/topic/78909-batch-convert-dxf-to-dwg/#comment-626951 * ;;;*********************************************************************************************************************** ;;;*********************************************************************************************************************** (defun C:DXF2DWG (/ fil tx1 tx2 tx3 tx4 tx5) (princ "Please select input folder. \n") (setq tx1 (vl-directory-files (setq tx2 (acet-ui-pickdir)) "*.dxf")) ; Select the folder containing *.dxf files to be imported. (princ "Please select output folder. \n") (setq tx3 (acet-ui-pickdir) ; Select folder for the *.dwg files to be exported into. tx4 "Default" ) (setvar "FILEDIA" 0) (foreach tx5 tx1 (if (wcmatch tx5 "*`.???") (setq tx5 (substr tx5 1 (- (strlen tx5) 4))) ) (command "_UNDO" "_MARK" "DXFIN" (strcat tx2 "\\" tx5) tx4 "" "" "_ZOOM" "_E" "._DELAY" 500 "_SAVEAS" "2018(LT2018)" (strcat tx3 "\\" tx5 ".dwg") "_N" ) (command "_ERASE" "ALL" "") ;erases everything on the page after the save (command "_.purge" "_all" "" "_no") ;purges everything so you don't carry it over to the next drawing (command "_.purge" "_regapp" "" "_no") (command "_QNEW") ;opens a new drawing (setvar "FILEDIA" 0) ) (princ) )
    1 point
  9. A simple modification, so : Find this line (setq sel (entsel "\nSelect Line : ")) And change it to this (setq sel (entsel (strcat "\nSelect Line " (itoa snum) " : "))) Pretty sure this should do what you want, but I can't test as I only have a LT version with me at the moment. If it doesn't work let me know and I can sort tomorrow. if you need to do the same for the text (when applicable) Change (setq sel (entsel "\nSelect Line Text : ")) ;TO (setq sel (entsel (strcat "\nSelect Line " (itoa snum) " Text : ")))
    1 point
  10. OK, try the attached. I have tested (and it is working. I have switched to selecting the line first as this is the common to both options. It will allow you to select "LINES", "LWPOLYLINES", "POLYLINES" and "3DPOLYLINES" for the line and "TEXT" or "MTEXT" for the text. It should ignore any MTEXT in line formatting To exit the loop select a blank area of the screen on the "Select Line : " prompt and answer "Yes" to the prompt (default is "No") to allow for missed lines. Making a blank selection at the "Select Text : " prompt will display a "Missed" alert and then just loop back to the "Select Text" prompt. Line lengths are currently decimal to 3 decimal places. xpd.lsp
    1 point
  11. For some reason i cant edit or delete the post above, but i think the below will make things easier to understand Thanks heaps dlanorh! To make it clearer, what we typically have is 3 items: a line, a line number (lets say 150, 151, 152 etc) and a number parameter for that line (usually 3, 4 or 5) So using this script we are currently able to get the length of the line, and relate it to the number parameter (3/4/5). So if the script can ask what the "start number" I can input for this job the start number is "150". Then the first line and text i pick is for line number 150, then the next ones are 151, then 152 etc. The reason for this is because every job is different - the next job the start number might be 200, or 1, or 250 etc. Very minor issue, but would help greatly. Number 2 you are correct, sometimes we don't need to know the number parameter, just the line length; and like above, hopefully we can relate that to the line number. The extra column is for the line number (IE 150, 151, 152 as per above). So the final script would hopefully be: 1. Run lisp 2. Ask for start number. User inputs start number (say 150) 3. Ask if Number parameter (3, 4, 5) is needed. user inputs Y or N 4a. if answer is Y, it will go pick number, pick line, pick number, pick line and so on 4b if the answer is no, it will go pick line, pick line, pick line 5a . Excel output example if answer is yes: Column A "start number" Column B "Number parameter" Column C "Line length" 150 3 2250 151 3 2400 152 5 1800 5b. If the answer is No: Column A "start number" Column B "Number parameter" Column C "Line length" 150 N/A 2250 151 N/A 2400 152 N/A 1800 So really the only difference is we have the option to choose whether we want to pick the number parameter (because to be honest a lot of the time we don't, so it means we are doing one extra click per line for no reason) and that we are giving the start number - as opposed to opening an excel file and the length just being in the first excel row - it will now have a number associated with it.
    1 point
×
×
  • Create New...