Recent Posts

Pages: [1] 2 3 ... 10
1
.NET / Re: How to add breaklines to Civil-3D surface in C#.NET?
« Last post by eddybeerke on Today at 03:19:12 AM »
...
Verry intresting topic.

I took some code from it to build my own solution to add multiple breaklines:

Code: [Select]
SelectionSet res = getSelectionSet();
if (res != null)
{
    PromptKeywordOptions pKeyOpts = new PromptKeywordOptions("");
    pKeyOpts.Message = "\nEnter the type of breakline to create: ";
    pKeyOpts.Keywords.Add("Standard");
    pKeyOpts.Keywords.Add("Non-Destructive");
    pKeyOpts.Keywords.Add("Proximity");
    pKeyOpts.Keywords.Default = "Standard";
    pKeyOpts.AllowNone = true;
    PromptResult pKeyRes = editor.GetKeywords(pKeyOpts);
    ObjectId[] lines;

    try
    {
        switch (pKeyRes.StringResult)
        {
            case "Non-Destructive":

                // Step through the objects in the selection set
                foreach (ObjectId acSSObj in res.GetObjectIds())
                {
                    lines = new ObjectId[] { acSSObj };
                    oSurface.BreaklinesDefinition.AddNonDestructiveBreaklines(new ObjectIdCollection(lines), 1);
                }
                break;
            case "Proximity":

                // Step through the objects in the selection set
                foreach (ObjectId acSSObj in res.GetObjectIds())
                {
                    lines = new ObjectId[] { acSSObj };
                    oSurface.BreaklinesDefinition.AddProximityBreaklines(new ObjectIdCollection(lines), 1);
                }
                break;
            case "Standard":
            default:
                // Step through the objects in the selection set
                foreach (ObjectId acSSObj in res.GetObjectIds())
                {
                    lines = new ObjectId[] { acSSObj };
                    //oSurface.BreaklinesDefinition.AddStandardBreaklines(new ObjectIdCollection(lines), 10, 5, 5, 0);
                    oSurface.BreaklinesDefinition.AddStandardBreaklines(new ObjectIdCollection(lines), 0.01, 2, 5, 0);
                }
                break;
        }
    }

    catch (System.Exception e)
    {
        editor.WriteMessage("Operation failed: {0}", e.Message);
    }

    // commit the transaction
    ts.Commit();
}
Code: [Select]
public SelectionSet getSelectionSet()
{
    //CivilDocument doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

    // Request for objects to be selected in the drawing area
    PromptSelectionResult acSSPrompt = ed.GetSelection();

    // If the prompt status is OK, objects were selected
    if (acSSPrompt.Status == PromptStatus.OK)
    {
        SelectionSet acSSet = acSSPrompt.Value;
        return acSSet;

    }
    return null;
}

2
.NET / Re: Losing Block Name
« Last post by retsameht on Today at 01:10:44 AM »
While developing an AutoCAD plugin in .NET, I encountered an issue where creating two new visibility states and setting this visibility to a block reference causes the block name to change to a format like UXXX (where X represents any digit). Although I can retrieve the original name from the dynamic table record, is there an alternative approach to prevent the block name from changing?

Your question was answered on the Autodesk .NET forum.  You can't prevent the block name from changing, and you shouldn't be relying on the names of anonymous blocks to start with.
3
Efficiency test, 510 entities, including 505 duplicate entities

Hash table efficiency far exceeds overkill

 

===============================

Command: tt
Select objects: Specify opposite corner: 510 found

Select objects:

===============================

Command: (tt1)

CPU:(1x)Intel(R) Xeon(R) E3-1575M v5 @ 3.00GHz 4Cores  / Memory:64G / OS: WIN10 professional workstation version
Benchmarking ......
Current settings: Tolerance=0.000001, Ignore=None, Optimize polylines=Yes, Combine partial overlap=Yes, Combine end-to-end=Yes
505 duplicate(s) deleted
0 overlapping object(s) or segment(s) deleted. done for 16 iterations. Sorted from fastest.
Statement                    Increment  Time(ms)  Normalize  Relative
-------------------------------------------------------------------------------
(xdrx-entity-removeduplic...)       16      1078         1078     28.07 <fastest>
(COMMAND ._-overkill SS  )          1       1891      30256       1.00 <slowest>
-------------------------------------------------------------------------------

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (setq ss (ssget))
  3.     (progn
  4.      (setq ss1 (xdrx-entity-copy ss))
  5.     )
  6.   )
  7.   (princ)
  8. )
  9. (defun tt1 ()
  10.   (xd::quickbench
  11.     '((command "._-overkill" ss "" "")
  12.       (xdrx-entity-removeduplicates ss1 129)
  13.      )
  14.   )
  15.   (princ)
  16. )
4
AutoLISP (Vanilla / Visual) / Re: Solid to surface
« Last post by ScottMC on May 24, 2024, 05:33:54 PM »
Is it a region? Another option Amarulu would be solidedit/face/copy and pick on the edge of the inner segment...
5
>>>>>
Here’s another example of a valiant attempt to extend lisp
https://www.theswamp.org/index.php?topic=45841.msg618986#msg618986

It’s very unfortunate




Yes, unfortunate is an understatement.  I'm baffled why AutoDesk can't provide a valid round-trip mechanism for values.

Really, really frustrating not being able to maintain the integrity of data.
6
AutoLISP (Vanilla / Visual) / Re: Turn all layout viewports ON-OFF in a drawing
« Last post by Ndruu on May 24, 2024, 12:04:26 PM »
Thank you all for the great suggestions and sorry for the late reply!
Unfortunately none of it worked for me hundred percent, but after some digging and fiddling I found a way to do it.
Thanks to Andrzej Kalinowski who wrote a description of his app https://autolisps.blogspot.com/p/viewporttools.html

To get the correct Viewport ID, you have to cycle through all layouts, that is unavoidable.
But the process takes more time as the number of layers grow in the drawing.
So the key is to freeze all the layers and then go through each layout. After that you can thaw back the layers with LAYERP.

Final simple code (no error trapping):

Code - Auto/Visual Lisp: [Select]
  1. (defun c:avpoff (/ old-ctab ss count ent llc i)
  2.   (setq old-ctab (getvar "ctab"))
  3.   (setq llc (length (layoutlist)))
  4.   (setq llc0 llc)
  5.   (command "-Layer" "freeze" "*" "")
  6.   (acet-ui-progress-init
  7.     (strcat "In progress ( Nr. of layouts " (rtos llc 2 0) " )")
  8.     llc
  9.   )
  10.   (setq i 0)
  11.   (foreach layout (layoutlist)
  12.     (if
  13.       (and (not (= (strcat layout) "MODEL"))
  14.            (setq ss (ssget "x" (list '(0 . "VIEWPORT") (cons 410 layout))))
  15.            (setvar 'ctab layout)
  16.       )
  17.        (progn
  18.          (setq count -1)
  19.          (setq i (1+ i))
  20.          (while (< (setq count (1+ count)) (1- (sslength ss)))
  21.            (setq ent (vlax-ename->vla-object (ssname ss count)))
  22.            (vla-display ent :vlax-false)
  23.            (vla-put-viewporton ent :vlax-false)
  24.            (acet-ui-progress-safe i)
  25.          )                              ;while
  26.        )
  27.     )                                   ;if
  28.   )                                     ;foreach
  29.   (acet-ui-progress-done)
  30.   (setvar 'ctab old-ctab)
  31.   (command "layerp")
  32.   (princ)
  33.   (setvar 'modemacro "")
  34.   (princ "\nDone!")
  35.   (alert "\nAll viewports are ON")
  36.   (princ)
  37. )
  38.  
  39. (defun c:avpon  (/ old-ctab ss count ent llc i)
  40.   (setq old-ctab (getvar "ctab"))
  41.   (setq llc (length (layoutlist)))
  42.   (setq old-layer (getvar 'clayer))
  43.   (command "-Layer" "freeze" "*" "")
  44.   (acet-ui-progress-init
  45.     (strcat "In progress ( Nr. of layouts: "
  46.             (rtos llc 2 0)
  47.             " )"
  48.     )
  49.     llc
  50.   )
  51.   (setq i 0)
  52.   (foreach layout (layoutlist)
  53.     (if
  54.       (and (not (= (strcat layout) "MODEL"))
  55.            (setq ss (ssget "x" (list '(0 . "VIEWPORT") (cons 410 layout))))
  56.            (setvar 'ctab layout)
  57.       )
  58.        (progn
  59.          (setq count -1)
  60.          (setq i (1+ i))
  61.          (while (< (setq count (1+ count)) (1- (sslength ss)))
  62.            (setq ent (vlax-ename->vla-object (ssname ss count)))
  63.            (vla-display ent :vlax-false)
  64.            (vla-put-viewporton ent :vlax-true)
  65.            (acet-ui-progress-safe i)
  66.          )                              ;while
  67.        )
  68.     )                                   ;if
  69.   )                                     ;foreach
  70.   (acet-ui-progress-done)
  71.   (setvar 'ctab old-ctab)
  72.   (command "layerp")
  73.   (princ)
  74.   (setvar 'modemacro "")
  75.   (princ "\nDone!")
  76.   (alert "\nAll viewports are ON")
  77.   (princ)
  78. )
7
Misunderstanding? Let’s say I have a key that’s a string, and a value that starts with a DXF code
(‘(“A”), ‘(11 11))
  Key       Value

Now I want to retrieve the value of ‘(“A”), I will get back (11.0 11.0 0.0). The value is wrong
I wanted two integers back, but I get back 3 doubles

Here’s another example of a valiant attempt to extend lisp
https://www.theswamp.org/index.php?topic=45841.msg618986#msg618986

It’s very unfortunate


8
My point is, you can’t use certain lists in the ‘value’ part of the map either, because what you put in, is not the same as what you get out

MapInsert ('(KEY) ‘(10 10)) may return ‘(10 10 0)
MapInsert ('(KEY) ‘(220 220 220 220))  LsAdsInvoke Internal Error

‘(220 220 220 220) This kind, because it is a BUG, cannot be passed from LISP to ARX at all, let’s not discuss it first.
'(10 10), when passed to ARX, will become a 3D point of '(10.0 10.0 0.0),
Insert into MAP, so '(10 10) under LISP can also query the index position INDEX through '(10.0 10.0 0.0), and then return the index to LISP for processing'(10 10)
9
My point is, you can’t use certain lists in the ‘value’ part of the map either, because what you put in, is not the same as what you get out

MapInsert ('(KEY) ‘(10 10)) may return ‘(10 10 0)
MapInsert ('(KEY) ‘(220 220 220 220))  LsAdsInvoke Internal Error
10
No, I don’t think I hashed the restype, just the value, but the value you get back can also be modified

vlia_k_v (‘(10 10 10) ‘(10 10))
or
vlia_k_v ‘(10 10 10) ‘'(220 220 220 220)

so it’s not really possible to build a generic unordered_map for lisp,  because there is some probability of a ;LsAdsInvoke Internal Error, or worse, corrupt data

'(220.0 220.0 220.0) and  '(210 220.0 220.0 220.0)

What I said about adding restype to hash calculation is to address the above points.
Within ARX, they are all considered to be 3D points. If calculated directly, their hash values will be the same.

======

Command: (xdrx_entity_hashstring '(220.0 220.0 220.0))
"17095823065452309527"
Command: (xdrx_entity_hashstring '(210 220.0 220.0 220.0))
"6635585597989606581"
Pages: [1] 2 3 ... 10