All Activity
- Past hour
-
Objects move away from Basepoint with Move Parameter (and they shouldn't)
CivilTechSource replied to ColinPearson's topic in AutoCAD 2D Drafting, Object Properties & Interface
You should be using Stretch instead of Move. Move will just move your block and it will not extend it as you mentioned. -
Danielm103 started following Extract vertices from a 3DSolid using ACIS data.
-
Extract vertices from a 3DSolid using ACIS data.
Danielm103 replied to dexus's topic in AutoLISP, Visual LISP & DCL
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 -
dexus started following 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 "") )
- Today
-
Extract vertices from a 3DSolid using ACIS data.
dexus replied to dexus's topic in AutoLISP, Visual LISP & DCL
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. -
Extract vertices from a 3DSolid using ACIS data.
hosneyalaa replied to dexus's topic in AutoLISP, Visual LISP & DCL
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 ;----- -
Extract vertices from a 3DSolid using ACIS data.
dexus replied to dexus's topic in AutoLISP, Visual LISP & DCL
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" "#") -
Travaci started following Rotate ucs on 3d object
-
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) ...
- Yesterday
-
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))
-
Geometric center of open polyline, line
BIGAL replied to maahee's topic in AutoLISP, Visual LISP & DCL
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. -
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
thanks master -
SELECT TEXTS OTHER THAN 3.5..HELP
Steven P replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
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 -
How to correctly extract nested objects from blocks with scaling/mirroring)
SLW210 replied to p7q's topic in AutoLISP, Visual LISP & DCL
Maybe something in my post or the one of Lee Mac's I linked... -
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/
-
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
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 -
Geometric center of open polyline, line
lrm replied to maahee's topic in AutoLISP, Visual LISP & DCL
@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". -
dexus started following Extract vertices from a 3DSolid using ACIS data.
-
Extract vertices from a 3DSolid using ACIS data.
dexus posted a topic in AutoLISP, Visual LISP & DCL
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 -
SELECT TEXTS OTHER THAN 3.5..HELP
Steven P replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
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. -
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
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 -
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
example.dwg -
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!
-
Geometric center of open polyline, line
maahee replied to maahee's topic in AutoLISP, Visual LISP & DCL
(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. -
Geometric center of open polyline, line
lrm replied to maahee's topic in AutoLISP, Visual LISP & DCL
@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. -
Perhaps not support LOFTNORMALS yet !!!! Thanks
-
Geometric center of open polyline, line
Saxlle replied to maahee's topic in AutoLISP, Visual LISP & DCL
Okay, this is the sub-function for calculating geometric center for open or closed polygon made from polyline. ; ******************************************************************************************* ; Sub-Function : SX:geomCenter ; Description : Geometric center for open or closed lwpolyline for 2D polygons ; Arguments: : ent - Selected entity into the drawing ; Calling function : (SX:geomCenter ent) ; Author : Saxlle ; Date : August 11, 2025 ; ******************************************************************************************* (defun SX:geomCenter ( ent / ptlist sum_x sum_y sum_area temp_area i len temp_x temp_y j cen_x cen_y cen_pt) (setq ptlist (mapcar 'cdr (vl-remove-if-not (function (lambda (x) (= (car x) 10))) (entget ent)))) ;; point list (if (and (equal (cdr (assoc 0 (entget ent))) "LWPOLYLINE") (>= (length ptlist) 3)) (progn (setq sum_x 0.0 sum_y 0.0 sum_area 0.0 temp_area 0.00 i 0 ) (repeat (setq len (length ptlist)) (if (< (1+ i) len) (progn (setq temp_area (- (* (car (nth i ptlist)) (cadr (nth (1+ i) ptlist))) (* (car (nth (1+ i) ptlist)) (cadr (nth i ptlist)))) sum_area (+ sum_area temp_area) temp_x (+ (car (nth i ptlist)) (car (nth (1+ i) ptlist))) temp_y (+ (cadr (nth i ptlist)) (cadr (nth (1+ i) ptlist))) sum_x (+ sum_x (* temp_x temp_area)) sum_y (+ sum_y (* temp_y temp_area)) i (1+ i) ) ) (progn (setq j 0 temp_area (- (* (car (nth i ptlist)) (cadr (nth j ptlist))) (* (car (nth j ptlist)) (cadr (nth i ptlist)))) sum_area (+ sum_area temp_area) temp_x (+ (car (nth i ptlist)) (car (nth j ptlist))) temp_y (+ (cadr (nth i ptlist)) (cadr (nth j ptlist))) sum_x (+ sum_x (* temp_x temp_area)) sum_y (+ sum_y (* temp_y temp_area)) ) ) ) ) (setq sum_area (/ sum_area 2)) (if (not (equal sum_area 0.0)) (setq cen_x (/ sum_x (* sum_area 6)) cen_y (/ sum_y (* sum_area 6)) cen_pt (list cen_x cen_y) ) ) (prompt (strcat "\nThe geometric center is: " (rtos cen_x 2 2) "," (rtos cen_y 2 2))) (princ) ) (progn (cond ((equal (cdr (assoc 0 (entget ent))) "LWPOLYLINE") (prompt "\nSelected entity is POLYLINE and the number of vertices are lower than 3! Need at least 3 or more vertices!") (princ) ) ((equal (cdr (assoc 0 (entget ent))) "LINE") (prompt "\nSelected entity is LINE and the center is the midpoint!") (princ) ) ) ) ) ) An example video of how it works. geomCenter.mp4 Best regards. -
Ok I have the "group by code" for descriptions. So next step is a look up for layer name to match the description. The description look would have like CIV3D description keys. Any way thought I posted try "EXPORTTOAUTOCAD" a CIV3D command to do just that convert CIV3D objects to plain Autocad objects. Here is the file to do what you want, but try export first. @devitg give it a try. spagetti.lsp