Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. I have a code to calculate and write the area of close polygons. I want to update the code to support in calculations rectangular parallelepiped. The problem is that in trapezoid calculation is a bug and if i select a rectangular parallelepiped calculate the area as trapezoid. Can someone fix the code? (defun c:areacal ( / AcDoc Space nw_style js nb ent dxf_ent ptlst n old_textsize count app_txt surf cum_area pt_ins val_txt lst_bis l_4d max_d pos pt1 pt2 pt3 d1 d2 h t_spc nw_obj ent_text key label scl ht *error*) (vl-load-com) ; Define error handler (defun *error* (msg) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " msg)) ) (setvar "OSMODE" 9) (mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight") (list "0" "BYLAYER" "BYLAYER" -1)) (if old_textsize (setvar "TEXTSIZE" old_textsize)) (vla-endundomark AcDoc) (princ) ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-startundomark AcDoc) (setvar "OSMODE" 0) ; Set scale and text height (setq scl (getvar "useri1")) (setq ht (* 0.003 scl)) ; Create ΚΕΙΜ_Layout layer if it doesn't exist (if (null (tblsearch "LAYER" "ΚΕΙΜ_Layout")) (vlax-put (vla-add (vla-get-layers AcDoc) "ΚΕΙΜ_Layout") 'color 7) ) ; Create ΚΕΙΜ_Layout text style if it doesn't exist (if (null (tblsearch "STYLE" "ΚΕΙΜ_Layout")) (progn (setq nw_style (vla-add (vla-get-textstyles AcDoc) "ΚΕΙΜ_Layout")) (mapcar '(lambda (pr val) (vlax-put nw_style pr val) ) (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag) (list (strcat (getenv "windir") "\\fonts\\arial.ttf") 0.0 0.0 1.0 0.0) ) ) ) ; Prompt for label prefix (setq label (getstring "\nInsert prefix (π.χ A,B,C..,etc): ")) (if (eq label "") (setq label "E")) ; Select polylines (prompt "\nSelect polylines one by one (press Enter to finish): ") (setq js (ssget '((0 . "LWPOLYLINE") (-4 . "<AND") (-4 . "&") (70 . 1) (-4 . ">") (90 . 2) (-4 . "<") (90 . 5) (-4 . "AND>")))) (if js (progn (repeat (setq nb (sslength js)) (setq ent (ssname js (setq nb (1- nb))) dxf_ent (entget ent) ptlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_ent)) n (length ptlst) ) (if (eq n 4) (if (and (not (equal (rem (angle (car ptlst) (cadr ptlst)) pi) (rem (angle (caddr ptlst) (cadddr ptlst)) pi) 1E-08)) (not (equal (rem (angle (cadr ptlst) (caddr ptlst)) pi) (rem (angle (cadddr ptlst) (car ptlst)) pi) 1E-08)) ) (ssdel ent js) ) ) ) ) ) (cond ((and js (> (sslength js) 0)) (sssetfirst nil js) (initget "Yes No") (if (not (eq (getkword "\n Insert calculations [Yes/No]? <Yes>: ") "No")) (progn (sssetfirst nil nil) (setq old_textsize (getvar "TEXTSIZE") count 0 app_txt "" cum_area 0.0 ) (setvar "TEXTSIZE" ht) ; Process polylines sequentially (0 to n-1) (setq nb 0) (while (< nb (sslength js)) (setq ent (ssname js nb) dxf_ent (entget ent) ptlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_ent)) n (length ptlst) pt_ins (list (/ (apply '+ (mapcar 'car ptlst)) n) (/ (apply '+ (mapcar 'cadr ptlst)) n)) val_txt (if (eq n 3) (progn (setq lst_bis (append (cdr ptlst) (list (car ptlst))) l_4d (mapcar 'distance ptlst lst_bis) max_d (apply 'max l_4d) pos (vl-position max_d l_4d) pt1 (nth pos ptlst) pt2 (nth pos lst_bis) pt3 (car (vl-remove pt2 (vl-remove pt1 ptlst))) d1 (distance pt3 (inters pt1 pt2 pt3 (polar pt3 (+ (angle pt1 pt2) (* pi 0.5)) (distance pt1 pt2)) nil ) ) surf (* (atof (rtos max_d 2 2)) (atof (rtos d1 2 2)) 0.5) cum_area (atof (rtos (+ surf cum_area) 2 3)) ) (strcat label (itoa (setq count (1+ count))) " = " "1/2 x " (rtos max_d 2 2) " x " (rtos d1 2 2) " = " (rtos surf 2 2) " τ.μ.\\P" ) ) (if (and (equal (abs (- (rem (angle (car ptlst) (cadr ptlst)) pi) (rem (angle (car ptlst) (cadddr ptlst)) pi))) (* 0.5 pi) 1E-08) (equal (abs (- (rem (angle (cadr ptlst) (caddr ptlst)) pi) (rem (angle (caddr ptlst) (cadddr ptlst)) pi))) (* 0.5 pi) 1E-08) ) (progn (setq d1 (atof (rtos (distance (car ptlst) (cadr ptlst)) 2 2)) d2 (atof (rtos (distance (cadr ptlst) (caddr ptlst)) 2 2)) surf (atof (rtos (* d1 d2) 2 2)) cum_area (atof (rtos (+ surf cum_area) 2 2)) ) (strcat label (itoa (setq count (1+ count))) " = " (rtos d1 2 2) " x " (rtos d2 2 2) " = " (rtos surf 2 2) " τ.μ.\\P" ) ) (progn (if (equal (rem (angle (car ptlst) (cadr ptlst)) pi) (rem (angle (caddr ptlst) (cadddr ptlst)) pi) 1E-08) (setq d1 (atof (rtos (distance (car ptlst) (cadr ptlst)) 2 2)) d2 (atof (rtos (distance (caddr ptlst) (cadddr ptlst)) 2 2)) h (atof (rtos (distance (car ptlst) (inters (car ptlst) (polar (car ptlst) (+ (angle (car ptlst) (cadr ptlst)) (* 0.5 pi)) 1.0) (caddr ptlst) (cadddr ptlst) nil)) 2 2)) ) (setq d1 (atof (rtos (distance (cadr ptlst) (caddr ptlst)) 2 2)) d2 (atof (rtos (distance (car ptlst) (cadddr ptlst)) 2 2)) h (atof (rtos (distance (cadr ptlst) (inters (cadr ptlst) (polar (cadr ptlst) (+ (angle (cadr ptlst) (caddr ptlst)) (* 0.5 pi)) 1.0) (car ptlst) (cadddr ptlst) nil)) 2 2)) ) ) (setq surf (atof (rtos (* (+ d1 d2) h 0.5) 2 2)) cum_area (atof (rtos (+ surf cum_area) 2 2)) ) (strcat label (itoa (setq count (1+ count))) " = 1/2 x (" (rtos d1 2 2) " + " (rtos d2 2 2) ") x " (rtos h 2 2) " = " (rtos surf 2 2) " τ.μ.\\P" ) ) ) ) app_txt (strcat app_txt val_txt) ) (entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") (cons 8 "ΚΕΙΜ_Layout") '(100 . "AcDbText") (cons 10 pt_ins) (cons 40 ht) (cons 1 (strcat label (itoa count))) (cons 50 (angle '(0 0 0) (getvar "UCSXDIR"))) '(41 . 1.0) '(51 . 0.0) (cons 7 "ΚΕΙΜ_Layout") '(71 . 0) '(72 . 1) (cons 11 pt_ins) (assoc 210 dxf_ent) '(100 . "AcDbText") '(73 . 2) ) ) (setq nb (1+ nb)) ) (initget "1 2") (setq t_spc (getkword "\n Insert calculations[1.Modelspace/2.Paperspace]? <1>: ")) (cond ((eq t_spc "2") (vla-put-ActiveSpace AcDoc acPaperSpace) (vla-put-MSpace AcDoc :vlax-false) (setq Space (vla-get-PaperSpace AcDoc)) (setvar "TEXTSIZE" 2.5) ) (T (vla-put-ActiveSpace AcDoc acModelSpace) (if (not (eq (getvar "TILEMODE") 1)) (vla-put-MSpace AcDoc :vlax-true)) (setq Space (vla-get-ModelSpace AcDoc)) (setvar "TEXTSIZE" ht) ) ) (setq nw_obj (vla-addMtext Space (vlax-3d-point (trans (getvar "VIEWCTR") 1 0)) 0.0 (strcat app_txt label "ολ = " (rtos cum_area 2 2) " τ.μ.") ) ) (mapcar '(lambda (pr val) (vlax-put nw_obj pr val) ) (list 'AttachmentPoint 'Height 'DrawingDirection 'StyleName 'Layer 'Rotation) (list 1 (getvar "TEXTSIZE") 5 "ΚΕΙΜ_Layout" "ΚΕΙΜ_Layout" 0.0) ) (setq ent_text (entlast) dxf_ent (entget ent_text) dxf_ent (subst (cons 90 1) (assoc 90 dxf_ent) dxf_ent) dxf_ent (subst (cons 63 255) (assoc 63 dxf_ent) dxf_ent) ) (entmod dxf_ent) (while (and (setq key (grread T 4 0)) (/= (car key) 3)) (cond ((eq (car key) 5) (setq dxf_ent (subst (cons 10 (trans (cadr key) 1 0)) (assoc 10 dxf_ent) dxf_ent)) (entmod dxf_ent) ) ) ) (setvar "TEXTSIZE" old_textsize) ) (T (sssetfirst nil nil) (princ "\nFunction canceled")) ) ) (T (princ "\nSelected items are invalid")) ) ; Reset system variables (mapcar 'setvar '("clayer" "cecolor" "celtype" "celweight") (list "0" "BYLAYER" "BYLAYER" -1)) (setvar "OSMODE" 9) (vla-endundomark AcDoc) (princ) ) Thanks test.dwg
  3. Today
  4. @CivilTechSource I'm looking to Move actually. I'm not really showing the cylinder that well, but the cylinder pokes out the bottom and pushes basically that whole box part upwards. Thank you for checking in on it though!
  5. You should be using Stretch instead of Move. Move will just move your block and it will not extend it as you mentioned. Is this what you are after? jack.dwg
  6. With ARX, you can use Brep or AssocPersSubentIdPE, the later is a bit simpler to use. AssocPersSubentIdPE will get you the faces, edges, and vertices of the solid. In the case of a cuboid, simply get all the edges and map them to a vertex In this example each vertex should be mapped to three edges. You could then build a transformation matrix so you can accurately compute the dimensions. It starts to get a lot harder with more complex shapes. There’s a few threads at the swamp discussing ideas how to work with I-beams, how to find the edge the run along the length for reference import traceback from pyrx import Ap, Ax, Ge, Ed, Db, command from collections import defaultdict @command def doit(): ps, id, pnt = Ed.Editor.entSel("\nPick it: \n", Db.Solid3d.desc()) solid = Db.Solid3d(id) pe = Db.AssocPersSubentIdPE(solid.queryX(Db.AssocPersSubentIdPE.desc())) edge_map = defaultdict(list[Ge.Curve3d]) for vrt in pe.getAllSubentities(solid, Db.SubentType.kVertexSubentType): edge_map[pe.getVertexSubentityGeometry(solid, vrt)] for edge in pe.getAllSubentities(solid, Db.SubentType.kEdgeSubentType): crv = pe.getEdgeSubentityGeometry(solid, edge) edge_map[crv.getStartPoint()].append(crv) edge_map[crv.getEndPoint()].append(crv) for k, v in edge_map.items(): for _crv in v: Ed.Core.grDraw(_crv.getStartPoint(), _crv.getEndPoint(), 1, 0) return
  7. dexus

    Rotate ucs on 3d object

    If you press enter with n3 the Z axis seems to keep pointing in the same direction, so this like works for me: (if (and (setq n1 (getpoint)) (setq n2 (getpoint)) ) (command "_.ucs" "_3p" n1 n2 "") )
  8. Thanks! Code works fine, but I do prefer not to explode the solids. And the EVSD function has a problem with points snapping to the wrong position, adding "_none" to copy command might fix that. The link you posted mentioned the xedges command, which works quite well. Still prefer to do it without drawing or exploding anything, but this code works good enough for now: (defun solid->pts (ent / itm rtn) (setq itm (entlast)) (command "_xedges" ent) (while (> (getvar "cmdactive") 0) (command "") ) (while (setq itm (entnext itm)) (setq rtn (vl-list* (vlax-curve-getStartPoint itm) (vlax-curve-getEndPoint itm) rtn ) ) (if (entget itm) (entdel itm) ) ) (removeDuplicates (vl-remove nil rtn)) ) ; RemoveDuplicates - MP ; https://www.theswamp.org/index.php?topic=4144.msg49515#msg49515 (defun RemoveDuplicates (lst / index) (vl-remove-if 'RemoveDuplicatesSub lst) ) (defun RemoveDuplicatesSub (x) (cond ((vl-position x index)) ((null (setq index (cons x index)))) ) ) If anyone knows how to do it with the acis data, I would still love to hear it.
  9. TRY @dexus https://www.theswamp.org/index.php?topic=59838.0 try this ;------------------------------------------------------------------------------- ; EVS extract_vertices_from_solid ; EVSD extract_vertices_from_solid and dwaw point ; EVSE extract_vertices_from_solid and erase solid ; EVSED extract_vertices_from_solid and erase solid and draw points ;------------------------------------------------------------------------------ ; Written by Giovanni Anzani, ; University of florence ; Departement DIDA of architecture ;--------------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------------- (defun c:EVS () (extract_vertices_from_solid (car (entsel "\nSelect solid:")) nil nil)) (defun c:EVSD () (extract_vertices_from_solid (car (entsel "\nSelect solid:")) nil T)) (defun c:EVSE () (extract_vertices_from_solid (car (entsel "\nSelect solid:")) T nil)) (defun c:EVSED () (extract_vertices_from_solid (car (entsel "\nSelect solid:")) T T)) ;------------------------------------------------------------------------------------------------- (defun CMD-0 () (setq cm_old (getvar "cmdecho" )) (setvar "cmdecho" 0 )) (defun OSM-0 () (setq os_old (getvar "osmode" )) (setvar "osmode" 0 )) (defun BLI-0 () (setq bl_old (getvar "blipmode" )) (setvar "blipmode" 0 )) ;-------------------------------------------------------------------------------------------------- (defun CMD-P () (setvar "cmdecho" cm_old )) (defun OSM-P () (setvar "osmode" os_old )) (defun BLI-P () (setvar "blipmode" bl_old )) ;-------------------------------------------------------------------------------------------------- (defun VAR-0 () (CMD-0) (OSM-0) (BLI-0)) (defun VAR-P () (CMD-P) (OSM-P) (BLI-P) (command "_redraw") (princ)) ;-------------------------------------------------------------------------------------------------- (defun Draw_lPu (lPu / Pu) (VAR-0) (foreach Pu lPu (vl-cmdf "._point" Pu)) (VAR-P)) ;-------------------------------------------------------------------------------------------------- (defun remove_duplicates_from_list (l_raw / element l_clean) (while l_raw (setq element (car l_raw) l_clean (cons element l_clean) l_raw (vl-remove element l_raw))) (reverse l_clean)) ;-------------------------------------------------------------------------------------------------- (defun entnext_from_ent_to_end (ent0 / ent1 lent) (while (setq ent1 (entnext ent0)) (setq lent (cons ent1 lent) ent0 ent1) lent)) ;-------------------------------------------------------------------------------------------------- ; if you want, you can eliminate duplicates (defun extract_edges_from_solid (ent0 erase_solid / Pu0 ent1 lis_ent) (setq Pu0 '(0.0 0.0 0.0)) (command-s "._copy" ent0 "" Pu0 Pu0) (setq ent1 (entlast)) (command-s "._copy" ent1 "" Pu0 Pu0) (repeat 2 (foreach ent (entnext_from_ent_to_end ent1) (command-s "._explode" ent ""))) (setq lis_ent (entnext_from_ent_to_end ent1)) (if erase_solid (command-s "._erase" ent0 ent1 "") (command-s "._erase" ent1 "")) lis_ent) ;--------------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------------- (defun extract_vertices_from_solid (ent0 erase_solid draw_points / eent Pu1 Pu2 lis_Pu) (foreach ent (extract_edges_from_solid ent0 erase_solid) (if ent (progn (setq eent (vlax-ename->vla-object ent) Pu1 (vlax-curve-getStartPoint eent) eent_open (not (vlax-curve-isClosed eent)) Pu2 (if eent_open (vlax-curve-getEndPoint eent))) (command-s "._erase" ent ""))) (if Pu1 (setq lis_Pu (if (member Pu1 lis_Pu) lis_Pu (cons Pu1 lis_Pu)))) (if Pu2 (setq lis_Pu (if (member Pu2 lis_Pu) lis_Pu (cons Pu2 lis_Pu))))) (setq lis_Pu (remove_duplicates_from_list lis_Pu)) (if draw_points (Draw_lPu lis_Pu)) lis_Pu) ;----------------------------------------------------------------------------------------------- ; EOF ;-----
  10. Below is the output I get from the routine, but I cant find where the transform is made... ("21800" "93" "2" "12" "" "" "" "" "" "" "" "" "" "") ("16" "\001utodesk" "\001uto\003\001\004" "19" "\001\023\r" "220.0.0.5400" "\016\024" "0" "" "") ("25.399999999999999" "9.9999999999999995e-007" "1e-010" "") ("asmheader" "$-1" "-1" "12" "220.0.0.5400" "#") ("body" "$-1" "-1" "$-1" "$2" "$-1" "$3" "#") ("lump" "$-1" "-1" "$-1" "$-1" "$4" "$1" "#") ("#") ("shell" "$-1" "-1" "$-1" "$-1" "$-1" "$5" "$-1" "$2" "#") ("face" "$6" "-1" "$-1" "$7" "$8" "$4" "$-1" "$9" "forward" "single" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$5" "1" "1" "2" "0" "#") ("face" "$10" "-1" "$-1" "$11" "$12" "$4" "$-1" "$13" "forward" "single" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$14" "$5" "#") ("plane-surface" "$-1" "-1" "$-1" "0" "100" "0" "-1" "0" "0" "0" "-1" "0" "forward\037v" "I" "I" "I" "I" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$7" "1" "1" "3" "0" "#") ("face" "$15" "-1" "$-1" "$16" "$17" "$4" "$-1" "$18" "forward" "single" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$19" "$7" "#") ("plane-surface" "$-1" "-1" "$-1" "100" "100" "0" "0" "1" "-0" "-1" "0" "0" "forward\037v" "I" "I" "I" "I" "#") ("coedge" "$-1" "-1" "$-1" "$20" "$21" "$22" "$23" "forward" "$8" "0" "$-1" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$11" "1" "1" "4" "0" "#") ("face" "$24" "-1" "$-1" "$25" "$26" "$4" "$-1" "$27" "forward" "single" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$28" "$11" "#") ("plane-surface" "$-1" "-1" "$-1" "100" "0" "0" "1" "0" "0" "0" "1" "0" "forward\037v" "I" "I" "I" "I" "#") ("coedge" "$-1" "-1" "$-1" "$29" "$30" "$31" "$32" "forward" "$12" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$33" "$14" "$34" "$35" "forward" "$8" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$14" "$33" "$29" "$36" "reversed" "$8" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$31" "$37" "$14" "$23" "reversed" "$38" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$39" "0" "$40" "100" "$14" "$41" "forward" "7" "unknown" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$16" "1" "1" "1" "0" "#") ("face" "$42" "-1" "$-1" "$43" "$44" "$4" "$-1" "$45" "forward" "single" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$46" "$16" "#") ("plane-surface" "$-1" "-1" "$-1" "0" "0" "0" "0" "-1" "0" "1" "0" "0" "forward\037v" "I" "I" "I" "I" "#") ("coedge" "$-1" "-1" "$-1" "$47" "$48" "$49" "$50" "forward" "$17" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$51" "$19" "$21" "$36" "forward" "$12" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$19" "$51" "$47" "$52" "reversed" "$12" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$49" "$22" "$19" "$32" "reversed" "$38" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$53" "0" "$39" "100" "$19" "$54" "forward" "7" "unknown" "#") ("coedge" "$-1" "-1" "$-1" "$21" "$20" "$55" "$56" "reversed" "$8" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$46" "$57" "$20" "$35" "reversed" "$26" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$40" "0" "$58" "100" "$34" "$59" "forward" "7" "unknown" "#") ("edge" "$-1" "-1" "$-1" "$39" "0" "$60" "100" "$29" "$61" "forward" "7" "unknown" "#") ("coedge" "$-1" "-1" "$-1" "$22" "$49" "$46" "$62" "reversed" "$38" "0" "$-1" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$37" "$43" "#") ("vertex" "$-1" "-1" "$-1" "$32" "1" "$63" "#") ("vertex" "$-1" "-1" "$-1" "$62" "0" "$64" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "100" "0" "0" "-1" "0" "\006" "0" "\006" "100" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$25" "1" "1" "1000000000" "2" "#") ("face" "$65" "-1" "$-1" "$-1" "$38" "$4" "$-1" "$66" "reversed" "single" "#") ("loop" "$-1" "-1" "$-1" "$-1" "$67" "$25" "#") ("plane-surface" "$-1" "-1" "$-1" "50" "50" "100" "0" "0" "1" "1" "0" "0" "forward\037v" "I" "I" "I" "I" "#") ("coedge" "$-1" "-1" "$-1" "$68" "$34" "$37" "$62" "forward" "$26" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$69" "$28" "$30" "$52" "forward" "$17" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$28" "$69" "$68" "$70" "reversed" "$17" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$37" "$31" "$28" "$50" "reversed" "$38" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$71" "0" "$53" "100" "$28" "$72" "forward" "7" "unknown" "#") ("coedge" "$-1" "-1" "$-1" "$30" "$29" "$73" "$74" "reversed" "$12" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$53" "0" "$75" "100" "$47" "$76" "forward" "7" "unknown" "#") ("vertex" "$-1" "-1" "$-1" "$50" "1" "$77" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "100" "0" "-1" "0" "0" "\006" "0" "\006" "100" "#") ("coedge" "$-1" "-1" "$-1" "$67" "$73" "$33" "$56" "forward" "$44" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$60" "0" "$58" "100" "$33" "$78" "forward" "7" "unknown" "#") ("coedge" "$-1" "-1" "$-1" "$34" "$68" "$67" "$79" "reversed" "$26" "0" "$-1" "#") ("vertex" "$-1" "-1" "$-1" "$35" "1" "$80" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "0" "0" "0" "0" "1" "I" "I" "#") ("vertex" "$-1" "-1" "$-1" "$36" "1" "$81" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "100" "0" "0" "0" "1" "I" "I" "#") ("edge" "$-1" "-1" "$-1" "$40" "0" "$71" "100" "$46" "$82" "forward" "7" "unknown" "#") ("point" "$-1" "-1" "$-1" "0" "100" "0" "#") ("point" "$-1" "-1" "$-1" "0" "0" "0" "#") ("persubent-acad\023olid\010istory-attrib" "$-1" "-1" "$-1" "$-1" "$43" "1" "1" "1000000000" "1" "#") ("plane-surface" "$-1" "-1" "$-1" "50" "50" "0" "0" "0" "1" "1" "0" "0" "forward\037v" "I" "I" "I" "I" "#") ("coedge" "$-1" "-1" "$-1" "$83" "$55" "$57" "$79" "forward" "$44" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$57" "$46" "$48" "$70" "forward" "$26" "0" "$-1" "#") ("coedge" "$-1" "-1" "$-1" "$48" "$47" "$83" "$84" "reversed" "$17" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$71" "0" "$85" "100" "$68" "$86" "forward" "7" "unknown" "#") ("vertex" "$-1" "-1" "$-1" "$62" "1" "$87" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "0" "0" "0" "1" "0" "\006" "0" "\006" "100" "#") ("coedge" "$-1" "-1" "$-1" "$55" "$83" "$51" "$74" "forward" "$44" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$75" "0" "$60" "100" "$51" "$88" "forward" "7" "unknown" "#") ("vertex" "$-1" "-1" "$-1" "$52" "1" "$89" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "100" "0" "0" "0" "1" "I" "I" "#") ("point" "$-1" "-1" "$-1" "100" "100" "0" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "100" "100" "0" "-1" "0" "I" "I" "#") ("edge" "$-1" "-1" "$-1" "$58" "0" "$85" "100" "$57" "$90" "forward" "7" "unknown" "#") ("point" "$-1" "-1" "$-1" "0" "0" "100" "#") ("point" "$-1" "-1" "$-1" "0" "100" "100" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "0" "0" "1" "0" "0" "\006" "0" "\006" "100" "#") ("coedge" "$-1" "-1" "$-1" "$73" "$67" "$69" "$84" "forward" "$44" "0" "$-1" "#") ("edge" "$-1" "-1" "$-1" "$85" "0" "$75" "100" "$69" "$91" "forward" "7" "unknown" "#") ("vertex" "$-1" "-1" "$-1" "$70" "1" "$92" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "0" "0" "0" "0" "1" "I" "I" "#") ("point" "$-1" "-1" "$-1" "100" "0" "0" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "100" "100" "-1" "0" "0" "I" "I" "#") ("point" "$-1" "-1" "$-1" "100" "100" "100" "#") ("straight-curve" "$-1" "-1" "$-1" "0" "0" "100" "1" "0" "0" "I" "I" "#") ("straight-curve" "$-1" "-1" "$-1" "100" "0" "100" "0" "1" "0" "I" "I" "#") ("point" "$-1" "-1" "$-1" "100" "0" "100" "#")
  11. Hello everyone, I want to do the following briefly. I'll specify two points, and it will automatically find the third point, then rotate it on the Z axis. This should work in both UCS and WCS. ... (setq n1 (getpoint)) (setq n2 (getpoint)) (command "_.ucs" "_3p" n1 n2 n3) (command "_.ucs" "ZA" n1 n2) ...
  12. Yesterday
  13. Some more. Note the Lst is sorted as in the spagetti code, sort on description 1st then point number. ; groupby provided by Dexus (defun _groupBy (fun lst0 / itm old rtn) (while lst0 (setq itm (fun (car lst0)) rtn (if (setq old (assoc itm rtn)) (subst (cons itm (cons (car lst0) (cdr old))) old rtn) (cons (cons itm (list (car lst0))) rtn) ) lst0 (cdr lst0)) ) rtn ) (setq lst2 (_groupBy (lambda (e) (car e)) lst))
  14. Just a out there way to get centroid, if you have a open pline then close it, use "Extrude" a height of say 10, then use "Massprop". Centroid: X= 0.388 Y= -3.101 Z= 5 Ok so choose the write to file option and read the centroid from the file, the sixth line. If you want the pline open then do a UNDO. Yes it will be a lisp, have used the write to file for concrete Tilt panels to mark the centroid.
  15. leonucadomi

    SELECT TEXTS OTHER THAN 3.5..HELP

    thanks master
  16. Steven P

    SELECT TEXTS OTHER THAN 3.5..HELP

    Ahh, that's my mistake, try this: (defun c:test (/ old_err EscVP StrScale2 TxtHt StrScale ss) (setq old_err *error*) (defun *error* ( a / ) ;; Add here return cmdecho to as it was, cmdecho 1 (princ "") (setq *error* old_err) (princ) ) ; End Error Defun (setvar "cmdecho" 0) ; perhaps record the state of cmdecho before here, and reset to that value at the end (if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) (= (cdr (assoc 0 (entget EntVP))) "VIEWPORT") ) ; end and (progn (setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP))) (setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1)) (setq TxtHt (* 3.5 (/ 1 EscVP)) ) ; a number not a string ;; added this (setq StrScale (rtos (/ 1 EscVP) 2 2)) (setq vpnum (cdr (assoc 69 (entget EntVP )))) (vl-cmdf "_.mspace") (setvar "CVPORT" vpnum) (setq ss (ssget (list '(0 . "TEXT") '(-4 . "<>") (cons 40 TxtHt))) ) ;; corrected line ;;What are you doing with ss now? (Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale)) (princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ") (princ StrScale2) ) ; end progn ) ; end if (setvar "cmdecho" 1) (princ) );fin defun
  17. Maybe something in my post or the one of Lee Mac's I linked...
  18. Thank you. I'll give it a try. Also found an interesting topic here that might help me achieve the kind of list I wanted. https://www.cadtutor.net/forum/topic/70713-add-itens-to-a-sublist/
  19. leonucadomi

    SELECT TEXTS OTHER THAN 3.5..HELP

    Master I'm trying the modified routine and this happens... (defun c:test (/ old_err EscVP StrScale2 TxtHt StrScale ss) (setq old_err *error*) (defun *error* ( a / ) ;; Add here return cmdecho to as it was, cmdecho 1 (princ "") (setq *error* old_err) (princ) ) ; End Error Defun (setvar "cmdecho" 0) ; perhaps record the state of cmdecho before here, and reset to that value at the end (if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) (= (cdr (assoc 0 (entget EntVP))) "VIEWPORT") ) ; end and (progn (setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP))) (setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1)) (setq TxtHt (* 3.5 (/ 1 EscVP)) ) ; a number not a string ;; added this (setq StrScale (rtos (/ 1 EscVP) 2 2)) (setq vpnum (cdr (assoc 69 (entget EntVP )))) (vl-cmdf "_.mspace") (setvar "CVPORT" vpnum) (setq ss (ssget (list(0 . "TEXT") (-4 . "<>") (cons 40 TxtHt))) ) ;;What are you doing with ss now? (Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale)) (princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ") (princ StrScale2) ) ; end progn ) ; end if (setvar "cmdecho" 1) (princ) );fin defun
  20. @maahee It is not clear what you want to calculate. Please respond to the following questions. Should the program be able to handle lines? ... lwpolylines without arc segments? ... lwpolylinese with arc segments? arc objects? circle objects? If the open/close property of a polyline is "open" sould the polyline be considered a closed shape defined by a line segment from the last vertex to the first vertex? The code in your last post dows nothing if the object is not a line. If it is a line it adds a dim line but does not identify the "center".
  21. Hello everyone, I'm trying to extract points/vertices from a 3D solid. The first way I tried was by exploding it into lines and arcs and then collecting the points. This works, but it is very slow. After that I found ACISdecode function by Kailas Dhage and used it to get some information about the 3D Solid. On a lot of 3D Solid it works and extracts the points correctly. But sometimes if I move the object, the point's inside of the ACIS data don't move. I'm trying to find where the transformation is stored so I can apply it to the exported points as well, but can't seem to find it. Code to export the points below, and an example drawing attached on which it doesn't work correctly. Hope someone can guide me in the right direction! (defun c:solid->pts ( / ent enx i rtn _acis) (defun _acis (enx / itm lin dxf str cha rtn) ; ACISdecode by Kailas Dhage (kailas@uts.com) ; Newsgroups: autodesk.autocad.customization 1999/05/10 ; Modified to work directly on entget data by dexus 2025/08/11 (while (setq dxf (assoc 1 enx)) (setq str (reverse (vl-string->list (cdr dxf))) itm nil lin nil) (while str (setq cha (car str) str (cdr str)) (cond ((= cha 95)) ((= cha 86) (setq itm (cons 73 itm))) ((= cha 32) (setq lin (cons (if itm (vl-list->string itm) "") lin) itm nil)) ((boole 6 cha 95) (setq itm (cons (boole 6 cha 95) itm))) ) ) (setq rtn (cons (cons (if itm (vl-list->string itm) "") lin) rtn) enx (cdr (member dxf enx))) ) (reverse rtn) ) (if (and (setq ent (car (entsel))) (setq enx (entget ent)) ) (foreach i (_acis enx) ; Princ result of the ACIS decode (princ "\n") (princ (vl-prin1-to-string i)) (if (and (equal (car i) "point") (> (length i) 5) (setq i (cddddr i))) (entmakex (list '(0 . "POINT") (cons 10 (list (distof (car i)) (distof (cadr i)) (distof (caddr i)) ) ) ) ) ) ) ) (princ) ) points.dwg
  22. Steven P

    SELECT TEXTS OTHER THAN 3.5..HELP

    Very quickly.... code tag is <> , you used quote tag '' which makes reading your code harder You use sssetfirst as a variable - it is better practice to not use a command name also as a variable even if it works. for example: (setq sssetfirst (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) ) ;; A variable (sssetfirst nil (ssget "_WP" ob_lst_pt '((0 . "*TEXT,ATTDEF")(-4 . "<NOT") (62 . 4) (-4 . "NOT>")) )) ;; A command The next suggestion I would make for now is to separate out your code a bit - all good running lines together but while you are creating something go to simple programming methods, it often makes errors or bad code jump out: (sssetfirst nil (ssget "_WP" ob_lst_pt '((0 . "*TEXT,ATTDEF")(-4 . "<NOT") (62 . 4) (-4 . "NOT>")) )) could be (setq MySS (ssget "_WP" ob_lst_pt '((0 . "*TEXT,ATTDEF")(-4 . "<NOT") (62 . 4) (-4 . "NOT>")) ) ) (sssetfirst nil MySS) Next thing would be to add comments to the code especially if you are asking how things work, we can read through the code quickly and see the intent of how the code works Last thing, when asking for help - and we have no problem with that - give a clue what is not working as it should. I think that if you add comments to the code it should be clear what to change to make the colours also red. Perhaps one of you comments will be 'adjust text to size 3.5'... and that might be where you want to change the colour also.
  23. leonucadomi

    SELECT TEXTS OTHER THAN 3.5..HELP

    Good morning, I'm going to explain the problem. I receive many dwg with different viewport scales, example 1:10,1:5, 1:8 etc... The texts in those viewports should have a height of 3.5 being in the paperspace What I do is that within the viewport I take a text and with the chspace command I put it in the paperspace and check in properties that its height is 3.5 If the text is correct in height, I copy the properties to others, sometimes they are just texts, sometimes there are also mtexts I would like a routine that just by touching the viewport will detect which of those texts do not meet the height I need, changing the color to red. Sometimes I just need to detect them and sometimes I need to modify them according to the instructions they give me. In this kind forum they guided me and I put together a routine that changes the size of the texts as I need it, but I would like to be able to make it only change the color of those that do not meet the height. here code
  24. leonucadomi

    SELECT TEXTS OTHER THAN 3.5..HELP

    example.dwg
  25. Hi everyone, I’ve been working on modifying Lee Mac’s “Extract Nested Block” routine. @Lee Mac By default, his code only extracts a nested block reference. I have expanded it so that it can also extract non-block objects (lines, arcs, etc.) located inside a nested block reference. The problem occurs when the selected object is inside one or more parent blocks that have been scaled or mirrored. In these cases, the extracted object is placed in the wrong position in model space. I know the “correct” way to solve this is to traverse the block reference hierarchy and apply all transformation matrices (scale, rotation, mirror) step by step until we reach world coordinates. However, in large DWG files with many nested blocks, this approach becomes very slow and hurts performance significantly. My question is: Is there a more efficient way to get the final WCS coordinates of a nested object, including all scaling/mirroring effects from its parent blocks, without manually multiplying all transformation matrices? Any suggestions or examples would be greatly appreciated. Thanks in advance!
  26. (defun C:Am (/ ss num i ent entdata p1 p2 p ang p_offset oldUcs) (if (setq ss (ssget '((0 . "LINE,LWPOLYLINE,ARC,CIRCLE")))) (progn (setq oldOsn (getvar "OSMODE")) ; Save current OSNAP modes (setvar "OSMODE" 0) ; Disable all object snaps (setvar "CMDECHO" 0) ; Disable command echo (command "_.undo" "_be") (setq num (sslength ss)) (setq i 0) (repeat num (setq ent (ssname ss i)) (setq entdata (entget ent)) (if (= (cdr (assoc 0 entdata)) "LINE") (progn (setq p1 (cdr (assoc 10 entdata))) (setq p2 (cdr (assoc 11 entdata))) ;; Calculate the angle (setq ang (angle p1 p2)) ;; Perpendicular point offset (setq p (polar p1 (+ ang (/ pi 2)) 0.2)) ;; Create aligned dimension (command "DIMALIGNED" p1 p2 p) ) ) (setq i (1+ i)) ) (setvar "OSMODE" oldOsn) ; Restore previous OSNAP modes (setvar "CMDECHO" 1) ) (alert "No entities selected.") ) ;; Restore UCS (princ) ) When executing AutoLisp, it works well, but whenever the UCS is shifted, running AutoLisp causes the dimensions of the same object to shift, resulting in a discrepancy between the dimensions and the object. This difference corresponds to the change between the old UCS and the new UCS.
  27. @devitg@Saxlle There seems to be some dissagreement of the definition of the geometric center of a polyline. Should the polyline be considered a linear object or a closed shape? If it's a linear object then the geometric center for an open polyline as shown below is (1.5,0.8) and not (1.5,0.5). There is no line from (3,0) to (0,0) that influeces the location of the geometric cener. My code above considers the polyline as a series of lines and not the bounds of a shape (which is ill defined as it is open). There is also the interpretation of how to handle a polyline that is "open" but should be considered a closed shape where the last vertex is assumed to be the same as the first vertex. In this case the polyline needs to be tested for the "closed" property and then appropriately dealt with to define a closed shape.
  28. Perhaps not support LOFTNORMALS yet !!!! Thanks
  1. Load more activity
×
×
  • Create New...