All Activity
- Past hour
-
@mhupp this may be useful, it captures command errors so after loading your lisp. You type say p2-3 on command line. Can do say p1-2, Pr3-2, prec1 0 and so on. ; test trap a command used as variable input ; BY Alan H 2019 ; now 2025 ( (lambda nil (vl-load-com) (foreach obj (cdar (vlr-reactors :vlr-command-reactor)) (if (= "fillet-reactor" (vlr-data obj)) (vlr-remove obj) ) ) (vlr-command-reactor "fillet-reactor" '((:vlr-unknowncommand . fillet-reactor-callback))) ) ) (defun fillet-reactor-callback ( obj com ) (setq com (car com)) (alert com) ; do the split com into ; (Change_Prec X X)) ) ; defun (or fillet-reactor-acdoc (setq fillet-reactor-acdoc (vla-get-activedocument (vlax-get-acad-object))) )
-
Whether with (ssget "_X" '((0 . "*") (-4 . "<NOT") (0 . "3DSOLID") (-4 . "NOT>"))) or (ssget "_X" (list (cons 0 "~3DSOLID"))), it also dismisses the entities TRACE et SOLID????
-
Thank you @marko_ribar much simpler. Added look in current Layout or Model. In Civ3D may find surfaces also that are not displayed. (ssget "_X" (list (cons 0 "~3DSOLID")(cons 410 (getvar 'ctab))))
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
mhupp replied to Clint's topic in AutoLISP, Visual LISP & DCL
Hit the X button bottom Right. -
K updated my code as well. tho this seems to not work well with BricsCAD. moved the vlax-put to only update when the if statment is true. change_prec_fields_update.lsp
-
I've modified my latest code to introduce current precision and search in the Mtext
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
BIGAL replied to Clint's topic in AutoLISP, Visual LISP & DCL
@Saxlle just a comment a bit hard to see what is going on in video maybe use a screen area rather than full screen. Win 11, Shit+Window+R allows screen area record. Drag window area then start / stop. This may be useful rather than a list box can tick one or all choices, add an All option so one click. Examples in code. Multi toggles.lsp - Today
-
marko_ribar started following Please help with this z0
-
(ssget "_X" (list (cons 0 "~3DSOLID")))
-
For some reason, the code only works in Text. When selecting MText, the precision does not change... Is it possible to assign the same precision or current precision to fields with different precision?
-
And with this syntax? (sssetfirst nil (ssget "_X" '((0 . "*") (-4 . "<NOT") (0 . "3DSOLID") (-4 . "NOT>"))))
-
With (initget) and (getkword) for choice precision... (vl-load-com) (defun c:change_prec ( / ss AcDoc Space prec_source ktarget n ename Obj value_string nbs tmp_nbs) (princ "\nSelect MText.") (while (null (setq ss (ssget (list '(0 . "*TEXT") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) ) ) ) ) (princ "\nAren't MText or Text!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (vla-startundomark AcDoc) (initget 1 "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Current") (setq ktarget (getkword "\nPrecision of target number [0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/Current]?: ")) (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) Obj (vlax-ename->vla-object ename) ) (setq value_string (vla-FieldCode Obj) nbs 0) (cond ((vl-string-search "%<\\" value_string nbs) (while nbs (if (setq nbs (vl-string-search "%pr" value_string (setq tmp_nbs nbs))) (setq prec_source (itoa (atoi (substr value_string (+ nbs 4) 2))) value_string (vl-string-subst (if (eq ktarget "Current") (strcat "%pr" (itoa (getvar "LUPREC"))) (strcat "%pr" ktarget) ) (strcat "%pr" prec_source) value_string tmp_nbs ) nbs (1+ nbs) ) ) ) (vlax-put Obj 'TextString value_string) ) ) ) (vla-endundomark AcDoc) (prin1) )
-
mhupp started following Changing the precision of fields and Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
mhupp replied to Clint's topic in AutoLISP, Visual LISP & DCL
Could go with a third Middle option. (setq layname (ApplyCASE "LAYERNAME")) LaYeRnAmE .... (defun ApplyCaSe (s / i n ch out) (setq n (strlen s) i 1 out "") (while (<= i n) (setq ch (substr s i 1)) (setq out (strcat out (if (= (rem i 2) 0) (strcase ch T) (strcase ch) ) ) ) (setq i (1+ i)) ) out ) -Edit or a more realistic Option Only first letter UpperCase (setq layname (ApplyCASE "LAYERNAME")) Layername (defun ApplyCase (s / i n ch out) (setq n (strlen s) i 2 out (strcase (substr s 1 1) T)) (while (<= i n) (setq ch (substr s i 1)) (setq out (strcat out (strcase ch)))) (setq i (1+ i)) ) out ) -
I'll have to debug it when i get home just typed it up in note pad. -Edit Well if i took two seconds to look at the code. was using integers and needs to be strings. because Tusky is calling vl-string-subst. if its still bugged ill fix it tonight.
-
Thanks, that's a good idea, but this code doesn't work for me.
-
Added a little on the front end to wrap it all in one command with user input options. Should display something like this Change_Prec or CP Enter "C" for Custom Values Choose Percision From:To : [1:2 1:3 2:1 2:3 3:1 3:2]: 3:2 Changing Select MText Precision From [3] to [2] ... Change_Prec or CP Enter "C" for Custom Values Choose Percision From:To : [1:2 1:3 2:1 2:3 3:1 3:2]: C Existing Precision: 1 Precision Change to: 4 Changing Select MText Precision From [1] to [4] ... Change_Prec 2 1 Changing Select MText Precision From [2] to [1] ... -Edit Updated it so you can just type "Change_Prec 3 2" and skip all that and just start asking you to make a selection.
-
I already tried it, but something strange happens: it filters the 3D solids, but it puts the other elements at z=1.0000E+99
-
DeEng started following Problem with Solid3d cylinder placement after CreateFrustum + TransformBy (AutoCAD .NET / C#)
-
I’m working on an AutoCAD .NET (C#) command that creates two Solid3d cylinders (one in +Z and one in –Z direction) starting from a selected point on an insulator line. Each cylinder is created with CreateFrustum, then moved into place using TransformBy(Matrix3d.Displacement) and optionally rotated around the point. However, I’ve run into a strange issue: sometimes the cylinders appear exactly in the correct place, but sometimes they shift several meters away from the point. In some cases both cylinders stack on each other, even though they should be separated along the Z-axis. The LIST command occasionally shows bounding boxes like: X = [-3500, 3500] Y = [-3500, 3500] Z = [-5000, 5000] which means the cylinder was never displaced at all, even though I definitely applied the transform. Here is the code that draws the cylinders: private void DrawClearanceCylinders(Database db, Editor ed, IEnumerable<Point3d> centers, double radius, double angleDeg) { if (centers == null) return; double h = CYL_LENGTH; double angRad = angleDeg * Math.PI / 180.0; using (var tr = db.TransactionManager.StartTransaction()) { var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); var btr = (BlockTableRecord)tr.GetObject( bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); foreach (var c in centers) { Solid3d cylUp = new Solid3d(); cylUp.SetDatabaseDefaults(); cylUp.CreateFrustum(h, radius, radius, radius); cylUp.TransformBy(Matrix3d.Displacement( new Vector3d(c.X, c.Y, c.Z))); if (Math.Abs(angleDeg) > 1e-6) cylUp.TransformBy(Matrix3d.Rotation(angRad, Vector3d.XAxis, c)); btr.AppendEntity(cylUp); tr.AddNewlyCreatedDBObject(cylUp, true); Solid3d cylDown = new Solid3d(); cylDown.SetDatabaseDefaults(); cylDown.CreateFrustum(h, radius, radius, radius); cylDown.TransformBy(Matrix3d.Displacement( new Vector3d(c.X, c.Y, c.Z - h))); if (Math.Abs(angleDeg) > 1e-6) cylDown.TransformBy(Matrix3d.Rotation(angRad, Vector3d.XAxis, c)); btr.AppendEntity(cylDown); tr.AddNewlyCreatedDBObject(cylDown, true); } tr.Commit(); } } The logic seems correct: create → displace → rotate → add to model space. But the result is inconsistent, and sometimes the displacement appears to be ignored. I’m trying to understand whether: CreateFrustum has an internal origin/transform I’m not accounting for the rotation around point c is interfering with the placement Solid3d requires a different transform order or if there’s a known issue with Solid3d placement after creation If anyone has experience with placing Solid3d cylinders precisely at a specific point, or knows what could cause the transforms to behave inconsistently, I’d really appreciate your insight. Command: LIST 6 found 3DSOLID Layer: "clerance_zone" Space: Model space Color: 4 (cyan) Linetype: "CONTINUOUS" Handle = 1000070 History = None Show History = No Bounding Box: Lower Bound X = 16294.5100, Y = 28025.7321, Z = -20484.5100 Upper Bound X = 24294.5100, Y = 36025.7321, Z = -10484.5100 3DSOLID Layer: "clerance_zone" Space: Model space Color: 4 (cyan) Linetype: "CONTINUOUS" Handle = 100006f History = None Show History = No Bounding Box: Lower Bound X = 16294.5100, Y = 28025.7321, Z = -10484.5100 Upper Bound X = 24294.5100, Y = 36025.7321, Z = -484.5100 3DSOLID Layer: "clerance_zone" Space: Model space Press ENTER to continue: Color: 4 (cyan) Linetype: "CONTINUOUS" Handle = 100006e History = None Show History = No Bounding Box: Lower Bound X = 1484.5100, Y = 32991.0000, Z = -20484.5100 Upper Bound X = 9484.5100, Y = 40991.0000, Z = -10484.5100 3DSOLID Layer: "clerance_zone" Space: Model space Color: 4 (cyan) Linetype: "CONTINUOUS" Handle = 100006d History = None Show History = No Bounding Box: Lower Bound X = 1484.5100, Y = 32991.0000, Z = -10484.5100 Upper Bound X = 9484.5100, Y = 40991.0000, Z = -484.5100 3DSOLID Layer: "clerance_zone" Space: Model space Color: 4 (cyan) Linetype: "CONTINUOUS" Handle = 100006c History = None Show History = No Thanks!
-
Help with 3D spur gear drawing (no tooth width given) !!
CyberAngel replied to Nlevismith95's topic in AutoCAD 3D Modelling & Rendering
Unfortunately, a lot of courses try to teach you to read plans as well as draw them. The information seems to be there, but you have to puzzle it out. One element of the tooth has two points of tangency and a radius. Once you draw that arc, you have the point of intersection with the outside radius. The outer width of the tooth is almost irrelevant to the design, because it's the last piece. The most important dimension seems to be the pitch, because that's where the teeth meet. Mechanical isn't really my field, so someone else will probably be able to give you better information. -
I have made several versions of the change_prec.lsp code. Maybe it will be useful to someone. Changing the precision of several fields =========================================================== change_prec_1-2.lsp === changing the precision of the fields from 1 to 2 change_prec_1-3.lsp === changing the precision of the fields from 1 to 3 change_prec_2-1.lsp === changing the precision of the fields from 2 to 1 change_prec_2-3.lsp === changing the precision of the fields from 2 to 3 change_prec_3-1.lsp === changing the precision of the fields from 3 to 1 change_prec_3-2.lsp === changing the precision of the fields from 3 to 2 =========================================================== change_prec_fields.lsp
-
tayyar joined the community
-
Nice test @PGia, thanks! For some reason I didnt consider closed polylines in the _checkOffset function, so I added an extra check there. Should work as expected now: Not sure about the short corner. The lines are so narrow the centerline is pushed back out of the point. Seems to be logical to me but it does feel intuitive. Narrow indents don't get much love from the centerline. So "inlets" don't have enough influence on the shape of the line. What would the expected result be? Below makes sense since there is not enough space to go into the indent. Or are you maybe something like this where the line splits and goes into the hole:
-
Here is the button macro for selected objects, so something like BIGAL's recommendation should work. ^C^C_SELECT;_MOVE;0,0,0;0,0,1e99;_MOVE;P;;0,0,0;0,0,-1e99;
-
@Tsuky thank you very much, your code changes the precision of the fields from 2 to 1. I replaced 2 lines in the code to change the precision from 1 to 2. (if (setq nbs (vl-string-search "%pr2" value_string (setq tmp_nbs nbs))) (setq value_string (vl-string-subst "%pr1" "%pr2" value_string tmp_nbs) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (if (setq nbs (vl-string-search "%pr1" value_string (setq tmp_nbs nbs))) (setq value_string (vl-string-subst "%pr2" "%pr1" value_string tmp_nbs) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * You've been very helpful!
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
Saxlle replied to Clint's topic in AutoLISP, Visual LISP & DCL
You're welcome @Clint . Yes, the DCL file are not necessary every time, but it can be helpful and user-friendly to accomplish desired result (like this one from an example video from above) if you have multiple choosing (for eg. buttons or check-boxes for Uppercase, Lowercase, Renaming, etc.). Best regards. -
You can try this. (vl-load-com) (defun c:change_prec ( / ss AcDoc Space n ename Obj value_string nbs tmp_nbs) (princ "\nSelect MText.") (while (null (setq ss (ssget (list '(0 . "*TEXT") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) ) ) ) ) (princ "\nAren't MText or Text!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (vla-startundomark AcDoc) (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) Obj (vlax-ename->vla-object ename) ) (setq value_string (vla-FieldCode Obj) nbs 0) (cond ((eq (substr (vla-FieldCode Obj) 1 3) "%<\\") (while nbs (if (setq nbs (vl-string-search "%pr2" value_string (setq tmp_nbs nbs))) (setq value_string (vl-string-subst "%pr1" "%pr2" value_string tmp_nbs) nbs (1+ nbs) ) ) ) (vlax-put Obj 'TextString value_string) ) ) ) (vla-endundomark AcDoc) (prin1) )
-
Hi BIGAL, Your point is well received! Best regards, Clint Hill
