Jump to content

All Activity

This stream auto-updates

  1. Today
  2. marko_ribar

    make pat files

    What happens if you type description : testpat and save file as testpat.pat P.S. I know this is old topic, but still I rarely use the code... Generated *.pat files are somewhat bad and produce undesired results... *.pat file must be very simple to make routine give desired output...
  3. 3dwannab

    make pat files

    @marko_ribar, If I give a description of test in my trial of this and save the file to testpat.pat then this is what it outputs. *test, test 42.22114819,0.,0.,1126.26190814,1241.17287848 Instead of: *testpat, test 42.22114819,0.,0.,1126.26190814,1241.17287848 Notice the first name proceeding the * must be the same as the file name. Currently it's putting the description for both.
  4. HI all. I usually change " Annotative properties Object " with command: Chrop > Select Object > Annotative > Make Annotative > Yes or No ? Can you help me shorten the command to do that? When use lisp will display option: Yes or No. Thanks all !
  5. Dear All, I have problem while stretching horizontal parameter, the vertical parameter skewed. In the 2nd visibility state having 2 pipes. Please find attached snap and dwg files. Thanks Krish ps903adesk.dwg
  6. BIGAL

    Lisp works in C3d, but not in Progecad

    Autocad has VLIDE Bricscad has Blade these are run time programs for developing lisp code included is "Debug" you can look at where code failed this would give us big clues about what is happening. I dont know if Progecad has similar. About all we can do without Progecad is to make you some test lines of code and see if they fail you would copy say the 1 line to the command line and hopefully it runs. (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) Should return #<VLA-OBJECT IAcadDocument 0000000063A064F8> etc (vlax-curve-getclosestpointto (car (entsel "\pick a line or pline")) (getpoint "\nPick near the object but not on it ")) Should return (55.2192513267315 108.828700429917 0.0) (X Y Z) of a point on the line/pline.
  7. here is another idea for clearing the screen. (defun MP:Screen->Clear () (setq screen-lines 50 cnt 0 ) (while (<= cnt screen-lines) (princ "\n") (setq cnt (1+ cnt)) ) (princ) ) lead the above function and then call it after all of your output.
  8. Yesterday
  9. Can anyone help me how to transfer object data from centroid table from AutoCAD Mep to Excel using Lisp. Proba.xlsx Proba.dwg
  10. Hello, reviving this thread as I'm working on an iteration of the code I worked on previously. I wanted to know if there are multiple blocks with the same name, and even same attribute into in them, how can I change them? In a broader sense, I'm trying to make a LISP that -> identifies the section markers -> retrieve the attribute information, position and all the states of the dynamic blocks (I know how to save the attribute info, but need help with the other stuff) -> deletes them and purges drawing (done) -> bring in new block from a different drawing and input the attribute information previously saved. (I'll figure this out afterwards, but I'm planning to save all the block info as variables and using them later) I've attached a sample of what I'm working with. Test For CADTutor.dwg
  11. Thanks - this way works, explodes a non-uniformly scaled block and retains polylines as polylines. Not enough hours this week to go my other way and modify each entity to the scales - still might be curious later on how to adjust ellipses though - might come back again in the future. (defun c:exp2 ( / ) (defun blockcomponents ( blk / ent rtn ) ;return list of bloc components, entity names, ref. Lee Mac (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq rtn (cons ent rtn)) ) ) (reverse rtn) ) (defun mAssoc (key lst /) ; return list of 'key' dotted pair values, ref. Lee Mac mAssoc (mapcar 'cdr (vl-remove-if-not (function (lambda (item) (= key (car item)))) lst)) ) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)) ) ; acad object name for VLA- (setq acad_blocks (vla-get-blocks thisdrawing) ) ; acad object name for VLA- (setq MyBlock (car (entsel "Block: "))) ; Select a block. No error checking done. (setq MyEnt (entget MyBlock)) ; Block enity definition ;;get block details (setq BlName (cdr (assoc 2 (entget MyBlock)))) ; Block name (setq xscale (cdr (assoc 41 MyEnt))) ; scale (setq yscale (cdr (assoc 42 MyEnt))) ; scale (setq zscale (cdr (assoc 43 MyEnt))) ; scale (setq Origin (cdr (assoc 10 MyEnt))) ; insert point (setq Rotation (* (/ (cdr (assoc 50 MyEnt)) pi ) 180)) ; Degrees (setq Blentities (blockcomponents BlName)) ; entity list entities in block ;;;Undo Mark (vla-startundomark thisdrawing) (foreach n BlEntities ; Loop through block entities (setq BlEnt (entget n)) ; 'n; Entity definition (setq EntType (cdr (assoc 0 BlEnt))) ; 'n' entity type (if (= (strcase EntType) "LWPOLYLINE") ; if 'n' is polyline (progn (setq LWCoords (mAssoc 10 BlEnt)) ; get polyline coordinates (foreach m LWCoords ; Loop through coordinates (setq NP (mapcar '* (list xscale yscale zscale) m)) ; Scale coordinate point (setq NP (mapcar '+ NP Origin)) ; Move to block origin (setq BlEnt (subst (cons 10 NP) (cons 10 m) BlEnt )) ; modify LWPolyline definition to this coord. ) (entmakex BlEnt) ; Create new polyline (vla-delete (Vlax-ename->vla-object n )) ; Delete polylines from block ) ; end progn ) ; end if ) ; end foreach (vla-regen acad_doc acallviewports) ; regen block (command "explode" MyBlock) ; Explode block. Use Burst? (vla-endundomark thisdrawing) ; End undo (princ) ; Exit quietly )
  12. Maybe these links will help Select Similar Shape in Autodesk Appstore Select Similar Shape in AppisCAD
  13. Can I move and rename Project.xml to outside of project root? I want to be able to search for the file. The powers to be keep using common names for projects and things. This makes it hard for me to know which project I am in. I could have two projects with the same name like the following: \common\2023\Project A \common\2024\Project A Is there a quick way to know which project you are in? Thanks, Michael
  14. Sambuddy

    Strick Tower Lisp

    Thanks for the reply, on your point 1) I tried all the itterations I could think of, but started losing the tapered line accuracy as it was no longer aligning with the rest of the "Main Leg". On your point 2) perhaps that is the right method, I honestly never though of that approach. So, basically, I would continue with the segments as is then draw a line to represent "Assembly length of the leg", I love that idea since I am stuck in modifying the draw-line function. On your point 3) The logic lies with the Engineer in charge and the calculations to base the bracing pattern or the existing tower on-site. So the logic is the Engineering part of the tower not a pre-defined set of logic. and your last point: I am drawing a 3D stick, so functions are degined to create each face equally the same type, shape and figure. Thank you greatly for your feedback and thoughts @CyberAngel
  15. CyberAngel

    Strick Tower Lisp

    Some preliminary thoughts. I have zero experience with towers, so feel free to dismiss everything. 1) You could add a vertical spacing parameter, which defaults to zero. In the draw-line subroutine, add the spacing parameter to the Z coordinate; if it's zero, no harm done. Wait, the vertical member isn't perpendicular to the ground? Use the interpolation function to locate that point. 2) If you need the vertical members for each segment to draw the next one up, could you put them on a separate layer? Then, when you're done, draw one line up the whole structure and erase the individual members. Or draw the one line first. 3) It would help if there was some logic behind the type of pattern, such as "K bracing in base, X in transition" or "Z bracing for width > 5000, X otherwise". Something else to consider: once you draw one side of the tower, can you mirror it or copy it correctly to make the other sides? That might save some effort and complexity.
  16. So basically this routine is creating a 3D stick model of a tower with specified segment height (that is the portion between each horizontal line), and connects the lines based on the base width and highest elevation width to form a trapazoidal/ conical shape as it graduates upward and in 2 flavours (3 legged and 4 legged supports). I cannot figure out the following no matter how much I tried: 1) I need to create a spacing between the diagonal bracings and the horizontal lines so that is user specified. Right now, every origin of the diagonal bracing starts at the end of the horizontal line. In some scenrios this is alright, but in many, i would need a vertical spacing of a user specified value to seperate the two as whon on my second photo. 2) The concept in general is wrong, as the number of segments should constitute the segments on the assembly that can be welded or bolted to bring to the site, what I have right now is small segments that will makeup the assembly but the tapared "main legs" should not be separated or broken (currently each segment is drawn to the point of intersecting with the next horizontal line). I would like to have "Assembly height" and then devise them into as many segments that makeup that portion on the assembly. 3) I would have liked to then (with #2 resolved) have the ability to chose what pattern bracing type I want for the next assembly (K/X/Z) onwards. 4) In VBA excel, with the help of simple graph, I can simulate what the tower would look like, and I am not sure if DCL and slides give me the preview (last photo is the userform in VBA, but I abandoned that idea and moved to lisp instead) I apologize in advance if I did not comment the lisp as much as I should have, but instead used a long variable name to describe the function/ variable I am sharing my thoughts and hopefully, you all wise people can share yours to solve my issues. (defun c:TOWER (/ draw-line draw-segment base-corners top-corners current-base-width current-top-width current-height original-ucs original-ortho original-osmode original-cecolor error-handler option shape base-width top-width num-segments segment-height ) ;; Prompt user for tower dimensions and number of segments (or base-width (setq base-width 8000.0)) (setq base-width (cond ((getdist (strcat "\nEnter Base Width " (strcat "< " (rtos base-width 2 3) " > :")))) (base-width))) (or top-width (setq top-width 4000.0)) (setq top-width (cond ((getdist (strcat "\nEnter Top Width " (strcat "< " (rtos top-width 2 3) " > :")))) (top-width))) (or num-segments (setq num-segments 10)) (setq num-segments (cond ((getint (strcat "\nEnter Number of Segments " (strcat "< " (rtos num-segments 2 0) " > :")))) (num-segments))) (or segment-height (setq segment-height 30480.0)) (setq segment-height (cond ((getdist (strcat "\nEnter Total Tower Height " (strcat "< " (rtos segment-height 2 3) " > :")))) (segment-height))) (setq segment-height (/ segment-height num-segments)) ;; Prompt user for shape type (4-sided or 3-sided) (initget "4 3") (setq shape (getkword "\nChoose Tower Geometry : [4/3]: ")) ;; Prompt user for bracing type (initget "K X Z") (setq option (getkword "\nChoose Bracing Type : [K/X/Z]: ")) ;; Save original settings (setq original-ortho (getvar 'orthomode)) (setq original-osmode (getvar 'osmode)) (setq original-cecolor (getvar 'CECOLOR)) ;; Error handler to restore settings (defun error-handler (msg) (if (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg))) (if (numberp original-ortho) (setvar 'orthomode original-ortho)) (if (numberp original-osmode) (setvar 'osmode original-osmode)) (if original-cecolor (setvar 'CECOLOR original-cecolor)) (princ) );end defun ;; Set UCS to World, Ortho to Off, and Object Snap to None or else it will fuck up the alignment (command "._ucs" "_world") (setvar 'orthomode 0) (setvar 'osmode 0) ;; Function to draw a line in 3D (defun draw-line (start end) (command "LINE" (list (nth 0 start) (nth 1 start) (nth 2 start)) (list (nth 0 end) (nth 1 end) (nth 2 end)) "") );end defun ;; Function to interpolate between two points (defun interp-coords (pt1 pt2 factor) (mapcar '(lambda (a b) (+ a (* factor (- b a)))) pt1 pt2)) ;; Function to draw a trapezoid segment (4-SIDED) (defun draw-segment-4 (base-corners top-corners) (setvar 'CECOLOR "24") (mapcar 'draw-line base-corners top-corners) (mapcar 'draw-line base-corners (append (cdr base-corners) (list (car base-corners)))) (mapcar 'draw-line top-corners (append (cdr top-corners) (list (car top-corners)))) );end defun ;; Function to draw a triangular segment (3-SIDED) (defun draw-segment-3 (base-corners top-corners) (setvar 'CECOLOR "24") (mapcar 'draw-line base-corners top-corners) (mapcar 'draw-line base-corners (append (cdr base-corners) (list (car base-corners)))) (mapcar 'draw-line top-corners (append (cdr top-corners) (list (car top-corners)))) );end defun ;; Function 4-sided tower bracing (defun draw-additional-lines-4 (base-corners top-corners option) (setvar 'CECOLOR "11") (cond ((equal option "K") (progn (draw-line (nth 0 base-corners) (interp-coords (nth 0 top-corners) (nth 1 top-corners) 0.5)) (draw-line (nth 1 base-corners) (interp-coords (nth 1 top-corners) (nth 2 top-corners) 0.5)) (draw-line (nth 2 base-corners) (interp-coords (nth 2 top-corners) (nth 3 top-corners) 0.5)) (draw-line (nth 3 base-corners) (interp-coords (nth 3 top-corners) (nth 0 top-corners) 0.5)) ;; Mirror lines to complete the K option pattern (draw-line (nth 0 base-corners) (interp-coords (nth 0 top-corners) (nth 3 top-corners) 0.5)) (draw-line (nth 1 base-corners) (interp-coords (nth 1 top-corners) (nth 0 top-corners) 0.5)) (draw-line (nth 2 base-corners) (interp-coords (nth 2 top-corners) (nth 1 top-corners) 0.5)) (draw-line (nth 3 base-corners) (interp-coords (nth 3 top-corners) (nth 2 top-corners) 0.5)))) ((equal option "X") (progn ;; Draw the X pattern on each exterior face ;; Face 1 (draw-line (nth 0 base-corners) (nth 1 top-corners)) (draw-line (nth 1 base-corners) (nth 0 top-corners)) ;; Face 2 (draw-line (nth 1 base-corners) (nth 2 top-corners)) (draw-line (nth 2 base-corners) (nth 1 top-corners)) ;; Face 3 (draw-line (nth 2 base-corners) (nth 3 top-corners)) (draw-line (nth 3 base-corners) (nth 2 top-corners)) ;; Face 4 (draw-line (nth 3 base-corners) (nth 0 top-corners)) (draw-line (nth 0 base-corners) (nth 3 top-corners)))) ((equal option "Z") (progn ;; Add lines to create the Z bracing pattern (draw-line (nth 0 base-corners) (nth 1 top-corners)) ;;Reverse (draw-line (nth 1 base-corners) (nth 2 top-corners)) (draw-line (nth 2 base-corners) (nth 1 top-corners)) ;;Reverse (draw-line (nth 2 base-corners) (nth 3 top-corners)) (draw-line (nth 3 base-corners) (nth 2 top-corners)) (draw-line (nth 3 base-corners) (nth 0 top-corners))))) );end defun ;; Function 3-sided tower bracing (defun draw-additional-lines-3 (base-corners top-corners option) (setvar 'CECOLOR "11") (cond ((equal option "K") (progn (draw-line (nth 0 base-corners) (interp-coords (nth 0 top-corners) (nth 1 top-corners) 0.5)) (draw-line (nth 1 base-corners) (interp-coords (nth 1 top-corners) (nth 2 top-corners) 0.5)) (draw-line (nth 2 base-corners) (interp-coords (nth 2 top-corners) (nth 0 top-corners) 0.5)) ;; Mirror lines to complete the K option pattern (draw-line (nth 0 base-corners) (interp-coords (nth 0 top-corners) (nth 2 top-corners) 0.5)) (draw-line (nth 1 base-corners) (interp-coords (nth 1 top-corners) (nth 0 top-corners) 0.5)) (draw-line (nth 2 base-corners) (interp-coords (nth 2 top-corners) (nth 1 top-corners) 0.5)))) ((equal option "X") (progn ;; Add lines to create the K bracing pattern (draw-line (nth 0 base-corners) (nth 2 top-corners)) (draw-line (nth 1 base-corners) (nth 0 top-corners)) (draw-line (nth 2 base-corners) (nth 1 top-corners)) ;; Add lines to complete the K bracing pattern (draw-line (nth 0 base-corners) (nth 1 top-corners)) (draw-line (nth 1 base-corners) (nth 2 top-corners)) (draw-line (nth 2 base-corners) (nth 0 top-corners)))) ((equal option "Z") (progn ;; Add lines to create the Z bracing pattern (draw-line (nth 0 base-corners) (nth 1 top-corners)) (draw-line (nth 1 base-corners) (nth 2 top-corners)) (draw-line (nth 2 base-corners) (nth 0 top-corners)))))) ;; Initialize dimensions for the first segment (setq current-base-width base-width) (setq current-top-width (+ base-width (/ (- top-width base-width) (float num-segments)))) (setq current-height 0) ;; Draw the segments based on shape/ geometry type (repeat num-segments (setq base-corners (if (equal shape "4") (list (list (- (/ current-base-width 2.0)) (- (/ current-base-width 2.0)) current-height) (list (- (/ current-base-width 2.0)) (/ current-base-width 2.0) current-height) (list (/ current-base-width 2.0) (/ current-base-width 2.0) current-height) (list (/ current-base-width 2.0) (- (/ current-base-width 2.0)) current-height)) (list (list (- (/ current-base-width 2.0)) (/ (* (sqrt 3) current-base-width) 6.0) current-height) (list (/ current-base-width 2.0) (/ (* (sqrt 3) current-base-width) 6.0) current-height) (list 0.0 (- (/ (* (sqrt 3) current-base-width) 3.0)) current-height))) top-corners (if (equal shape "4") (list (list (- (/ current-top-width 2.0)) (- (/ current-top-width 2.0)) (+ current-height segment-height)) (list (- (/ current-top-width 2.0)) (/ current-top-width 2.0) (+ current-height segment-height)) (list (/ current-top-width 2.0) (/ current-top-width 2.0) (+ current-height segment-height)) (list (/ current-top-width 2.0) (- (/ current-top-width 2.0)) (+ current-height segment-height))) (list (list (- (/ current-top-width 2.0)) (/ (* (sqrt 3) current-top-width) 6.0) (+ current-height segment-height)) (list (/ current-top-width 2.0) (/ (* (sqrt 3) current-top-width) 6.0) (+ current-height segment-height)) (list 0.0 (- (/ (* (sqrt 3) current-top-width) 3.0)) (+ current-height segment-height))))) ;; Draw the tower segment (if (equal shape "4") (draw-segment-4 base-corners top-corners) (draw-segment-3 base-corners top-corners)) ;; Draw the bracings (if (equal shape "4") (draw-additional-lines-4 base-corners top-corners option) (draw-additional-lines-3 base-corners top-corners option)) ;; Update dimensions for the next segment (setq current-base-width current-top-width) (setq current-top-width (+ current-base-width (/ (- top-width base-width) (float num-segments)))) (setq current-height (+ current-height segment-height))) ;; Restore original settings (if (numberp original-ortho) (setvar 'orthomode original-ortho)) (if (numberp original-osmode) (setvar 'osmode original-osmode)) (if original-cecolor (setvar 'CECOLOR original-cecolor)) ;; Clean up and exit (setq *error* nil) ;; Main function with error trapping (setq *error* error-handler) (setvar 'CECOLOR "BYLAYER") ; Ensure CECOLOR is set to a valid value (princ) (vla-regen (vla-get-activeDocument (vlax-get-acad-object)) acAllViewports); Regenerate active sheet );end defun ;start the routine (c:TOWER)
  17. Could do - this is a work in progress and part 2 of his original problem - moving and scaling a set of objects from one coordinate system to another (mapping). It is just the polyline that he was having problems with so might be a better solution, take them out, scale, explode block.
  18. For blocks you are forced to use the code I edited which only processes the selected entity: the reason is that I use (nentsel) to retrieve the nested entity, which I cannot do with a (ssget) as in the code I put in the attached file.
  19. Type the command RESETBLOCK, then select all blockreferences which you want to reset.
  20. @X11start Just add the dxf code for color (setq selpol-a4 (ssget (LIST (cons -4 "<AND") (cons 0 "LWPOLYLINE") (cons 8 "ZZ_CARPENTERIA") (cons 62 colornumber) ; seem to be orange (cons -4 "AND>") ) )) or (setq selpol-a3 (ssget (LIST (cons -4 "<AND") (cons 0 "LWPOLYLINE") (cons 8 "ZZ_FORMED") (cons 62 colornumber) ; seem to be gray 9 (cons -4 "AND>") ) ))
  21. tricon77

    counting blocks

    You are on the right track, but the prefix can be any character but a #. Looks like I messed up on the last c blocks in the previous attach file because there is no # in the name. I have attached more realistic example. Thank you for your help, Michael demo.dwg
  22. Thinking out loud: could you override the Explode function, pull out the polylines and ellipses, and pass everything else to the normal Explode? You'd have to redraw the polylines and ellipses, but you have their positions and scales from the block definition. Or you could pass the other objects directly to model space and erase the block.
  23. Mr Tusky, I appreciate you, realy it is a good job. Thanks So how do choose those who touch the blocks?
  24. This is one that came up this week, wondering if anyone has anything they can share: They want to explode a block with different X and Y scales - all good except polylines appear also get exploded unless the X & Y scales are equal. Not a problem to create a function for lines and polylines to explode and retain polylines as polylines. Now onto the others..... Text, mtext and nested blocks are just trigonometry to adjust the UCS X and Y but ellipse.... I could make a block the ellipses, scale x-y then explode, which is the usual method, easy enough... but why go easy.... So question - does anyone have a LISP that can scale / stretch an ellipse along a single axis only?
  25. It's doable, but in this case I can no longer use the blocks as a source. You can use _QSELECT (or SELECTSIMILAR) or nothing at all for manual selection before using the code. sel_by_obj-touch(bis).lsp
  26. CyberAngel

    Lisp works in C3d, but not in Progecad

    You probably need this command at the beginning: (vl-load-com) which loads the library for all the Visual LISP commands--as you might expect from the name.
  1. Load more activity
×
×
  • Create New...