Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by ancrayzy on Today at 12:01:12 AM »
Thank you very much for your reply Mr John Kaul (Se7en), it makes a lot of sense.
I put the code together and couldn't find the command line, that's why I need help with a complete lisp file.
And another reason is that I don't know how to write auto lisp command  :embarrassed2:
2
.NET / Re: .NET application error in AC2022 but not AC2017
« Last post by CADbloke on December 06, 2021, 10:38:57 PM »
What type of object is throwing the error? Is the type or object consistent. Does running an AUDIT command or Database.Audit at any stage help? The AUDIT command is AutoCAD's version of the "This is fine" meme. Ho are you toggling the attribute display? ATTDISP command?

Perhaps try RecordGraphicsModified(true) on the Attributes and/or block insertions ? That's probably just for rendering so it may not be relevant. Does the Attribute visibility make a difference to the crashiness?
3
.NET / Re: .NET application error in AC2022 but not AC2017
« Last post by Keith™ on December 06, 2021, 09:36:52 PM »
The way the application works is that the user selects data files to import into the drawing. The data is processed and then an insert jig is called to insert the block. After processing all of the data and inserting all of the blocks the application then turns off attributes visibility based on its value.

The blocks are inserted without issue and then the error is thrown.

I initially thought it was the toggle routines but then if I use the toggle functions alone, they work fine and do not throw an error.
4
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by John Kaul (Se7en) on December 06, 2021, 09:25:37 PM »
Put the first block and either the second block--or third block--into a file and load into AutoCAD with "appload".

The first block of code is the support functions. The second code block is the actual "usage code" (this is how you use the support functions in the first block of code). The third block of code represents an example; it represents a procedure you are writing (it is just another example).

Ultimately (if you use the code I or Thwart posted), you need to create a function you can call from the command line. I--or many others here--can teach you how to write a function if you want to learn. However, if you only want me to create a ready made solution, please understand that I don't like posting ready made functions for people (I would much rather teach you to fish on your own then give you a fish every time you're hungry; that is how you build a community).


Hi John Kaul (Se7en),
I am a writer on cadtutor.net,
https://www.cadtutor.net/forum/topic/74116-lisp-to-count-text-and-layers/
Thank you very much for this article.
I saw the link and saw your post here but I still don't know how to combine the above code.
Do I just copy and combine all the code in that post into a single lisp and use it

Regards,
5
.NET / Re: .NET application error in AC2022 but not AC2017
« Last post by CADbloke on December 06, 2021, 08:54:30 PM »
I build CAD Replace with the v2013 libraries and .NET 4.7.2 - I have never seen that error, even in the even-more-buggy-than-before ACAD 2022.

Is any of the processing done off the UI thread?
6
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by ancrayzy on December 06, 2021, 08:52:27 PM »
Hi John Kaul (Se7en),
I am a writer on cadtutor.net,
https://www.cadtutor.net/forum/topic/74116-lisp-to-count-text-and-layers/
Thank you very much for this article.
I saw the link and saw your post here but I still don't know how to combine the above code.
Do I just copy and combine all the code in that post into a single lisp and use it

Regards,
7
.NET / Re: .NET application error in AC2022 but not AC2017
« Last post by Keith™ on December 06, 2021, 05:27:39 PM »
Well, I'm going to recompile with the 2022 libraries and see if that makes a difference, but I've got to rebuild my WM and reinstall the software.
Apparently the VM I have been using doesn't support .NET4.7 and that is the minimum requirement to build to the 2022 libraries.
8
AutoLISP (Vanilla / Visual) / COPIED: Maximum sum of sub array
« Last post by John Kaul (Se7en) on December 06, 2021, 04:37:07 PM »
For those of you that do not visit the General Programing forum, This is a link to a challenge you may find fun to participate in.

This is a copy/link to a post in the  General Programming (was C++) forum. Please post your answers there. This thread may be removed later.

https://www.theswamp.org/index.php?topic=57208.0
9
.NET / Re: .NET BLOCK Routines
« Last post by kelcyo on December 06, 2021, 04:31:46 PM »
Hi Gile, I just insert the block into the uploaded drawing in places determined by a list of points. I'm working with current version 2022.

Code: [Select]
// Get the current UCS Z axis (extrusion direction)
Matrix3d ucsMat = ed.CurrentUserCoordinateSystem;
CoordinateSystem3d ucs = ucsMat.CoordinateSystem3d;
Vector3d zdir = ucsMat.CoordinateSystem3d.Zaxis;

// Get the OCS corresponding to UCS Z axis
Matrix3d ocsMat = MakeOcs(zdir);

// Transform the input point from UCS to OCS
//Point3d pt = ppr.Value.TransformBy(ucsMat.PreMultiplyBy(ocsMat));

// Get the X axis of the OCS
Vector3d ocsXdir = ocsMat.CoordinateSystem3d.Xaxis;

// Get the UCS rotation (angle between the OCS X axis and the UCS X axis)
double rot = ocsXdir.GetAngleTo(ucs.Xaxis, zdir);

BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

// Foreach in points collection
foreach (Point3d item in _pcIns)
{
    BlockReference br = new BlockReference(item, bt["MDF"]);
    br.Position = item;
    br.Rotation = rot;
    br.Normal = zdir;
    btr.AppendEntity(br);
    tr.AddNewlyCreatedDBObject(br, true);   

}

ObjectIdCollection brefIds = btr.GetBlockReferenceIds(false, true);
foreach (ObjectId id in brefIds)
{
    BlockReference bref = (BlockReference)tr.GetObject(id, OpenMode.ForWrite, false, true);
    bref.RecordGraphicsModified(true);
}

btr.SynchronizeAttributes();

tr.Commit();
10
AutoLISP (Vanilla / Visual) / Re: Lisp to count text in drawing
« Last post by Tharwat on December 06, 2021, 04:28:07 PM »
Here is my attempt which returns a list as shown below and hopefully they won't have Mtexts formatted otherwise unformatting function required to strip strings.
Code - Auto/Visual Lisp: [Select]
  1. (and (setq s (ssget "_X" '((0 . "TEXT,MTEXT"))))
  2.      (repeat (setq i (sslength s))
  3.        (setq i (1- i)
  4.              e (entget (ssname s i))
  5.              l (list (cdr (assoc 1 e)) (cdr (assoc 8 e)))
  6.              )
  7.        (or (and (vl-some (function (lambda (q) (and (= (car q) (car l)) (= (cadr q) (cadr l)) (setq r q)))) g)
  8.                 (setq g (vl-remove r g)
  9.                       g (cons (append l (list (1+ (caddr r)))) g)
  10.                       )
  11.                 )
  12.            (setq g (cons (append l (list 1)) g))
  13.            )
  14.        )
  15.      )
  16.  
  17. ;; Returns:
  18. ;; (("Abc" "Layer1" 20) ("xyz" "Layer2" 3) ("tt" "Layer2" 1) ("xx" "Walls" 1))
  19.  
Pages: [1] 2 3 ... 10