Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: Make (entlast) work like (entsel)
« Last post by GDF on Today at 01:17:27 pm »
Thanks Roy

2
AutoLISP (Vanilla / Visual) / Re: Make (entlast) work like (entsel)
« Last post by GDF on Today at 01:16:36 pm »
@GDF:
Why don't you use:
Code: [Select]
(list (entlast) pt1)instead of:
Code: [Select]
(list (lastline) mid)?
Code - Auto/Visual Lisp: [Select]
  1. (defun C:WW2 ( / entselLst pt1 pt2 pt3)
  2.  (ARCH:F_S-VAR)
  3.  (setq pt1 (getpoint "\n* Pick beginning point *"))
  4.  (setq pt2 (getpoint pt1 "\n* Pick the end point *"))
  5.  (command "_.line" pt1 pt2 "")
  6.  (setq entselLst (list (entlast) pt1))
  7.  (setq pt3 (getpoint "\n* Specify offset direction --> "))
  8.  (command "_.offset" "3.5" entselLst pt3 "")
  9.  (ARCH:LYR "A-WALL-FULL")
  10.  (command "_.chprop" "_last" "" "_layer" "A-WALL-FULL" "")
  11.  (command "_.offset" "9.0" entselLst pt3 "")
  12.  (ARCH:LYR "A-WALL-EXT")
  13.  (command "_.chprop" "_last" "" "_layer" "A-WALL-EXT" "")
  14.  (ARCH:F_R-VAR)
  15.  (princ)
  16. )
3
AutoLISP (Vanilla / Visual) / Re: Make (entlast) work like (entsel)
« Last post by roy_043 on Today at 04:53:33 am »
@GDF:
Why don't you use:
Code: [Select]
(list (entlast) pt1)instead of:
Code: [Select]
(list (lastline) mid)?
Code - Auto/Visual Lisp: [Select]
  1. (defun C:WW2 ( / entselLst pt1 pt2 pt3)
  2.  (ARCH:F_S-VAR)
  3.  (setq pt1 (getpoint "\n* Pick beginning point *"))
  4.  (setq pt2 (getpoint pt1 "\n* Pick the end point *"))
  5.  (command "_.line" pt1 pt2 "")
  6.  (setq entselLst (list (entlast) pt1))
  7.  (setq pt3 (getpoint "\n* Specify offset direction --> "))
  8.  (command "_.offset" "3.5" entselLst pt3 "")
  9.  (ARCH:LYR "A-WALL-FULL")
  10.  (command "_.chprop" "_last" "" "_layer" "A-WALL-FULL" "")
  11.  (command "_.offset" "9.0" entselLst pt3 "")
  12.  (ARCH:LYR "A-WALL-EXT")
  13.  (command "_.chprop" "_last" "" "_layer" "A-WALL-EXT" "")
  14.  (ARCH:F_R-VAR)
  15.  (princ)
  16. )
4
AutoLISP (Vanilla / Visual) / Re: Change select all to select simple
« Last post by Chris on April 28, 2017, 09:11:45 pm »
I dont think it will be that simple.  to select attributes within a block, you'd either have to explode the block or find some way to pass the cooridinate of selection point into the program and somehow associate the point with the attribute within the block.
5
AutoLISP (Vanilla / Visual) / Change select all to select simple
« Last post by amc.dicsac on April 28, 2017, 04:44:25 pm »
Hi, how are you:

I have the following lisp that changes the height of all the texts, that are within the block. The problem is that it makes a total selection, I would like to change to a simple selection using ssget, I hope they can help me thanks.


Code - Auto/Visual Lisp: [Select]
  1. (defun ChangeAllTextAltura (Doc Alt / IsLo tempObjType)
  2. (setq IsLo (if (= (vla-get-IsLayout Blk) :vlax-true) T nil))
  3. (if (= (vla-get-IsXref Blk) :vlax-false)
  4.  (vlax-for Obj Blk
  5.   (setq tempObjType (vla-get-ObjectName Obj))
  6.   (cond
  7.    ((vl-position tempObjType '("AcDbText" "AcDbMText" "AcDbAttributeDefinition"))
  8.     (vla-put-Height Obj Alt)
  9.     (if (not IsLo)
  10.      (vla-put-Layer Obj "0")
  11.     )
  12.    )
  13.    ((wcmatch tempObjType "AcDb*Dimension")
  14.     (vla-put-Height Obj Alt)
  15.    )
  16.    ((= tempObjType "AcDbBlockReference")
  17.     (foreach Att (vlax-invoke Obj 'GetAttributes)
  18.      (vla-put-Height Att Alt)
  19.     )
  20.     (foreach Att (vlax-invoke Obj 'GetConstantAttributes)
  21.      (vla-put-Height Att Alt)
  22.     )
  23.    )
  24.   )
  25.  )
  26. )
  27. )
  28. )



Code - Auto/Visual Lisp: [Select]
  1. (defun c:TH ()
  2. ([font=Verdana][size=2px]ChangeAllTextAltura [/size][/font] (vla-get-ActiveDocument (vlax-get-Acad-Object)) 0.15)
  3. (command "regenall")
6
.NET / Bricscad: Help with WBlockCloneObjects
« Last post by Keith Brown on April 28, 2017, 03:52:24 pm »
I have some code that I am trying to port over to Bricscad.  The code is supposed to create a new drawing and then xref the current drawing into it.  It will copy some views from the current drawing into the new drawing and then save and exit the new drawing.  The code that I have is working just fine in AutoCAD but when I run it in Bricscad it gives me the dreaded EInvalidOwnerObject when i use the WBlockCloneObject command.


Here is the stripped down code that I am using.  Any ideas?


Code - C#: [Select]
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;    
  5. using System.Windows.Forms;
  6.  
  7. #if BricsCAD
  8.    using System.Runtime.InteropServices;
  9.    using BricscadApp;
  10.    using Teigha.Runtime;
  11.    using Teigha.DatabaseServices;
  12.    using Teigha.GraphicsInterface;
  13.    using Teigha.Geometry;
  14.    using Bricscad.ApplicationServices;
  15.    using Bricscad.EditorInput;
  16.    using Bricscad.Runtime;
  17.    using CadRx = Teigha.Runtime;
  18.    using CadAs = Bricscad.ApplicationServices;
  19.    using CadApp = Bricscad.ApplicationServices.Application;
  20.    using CadBr = Teigha.BoundaryRepresentation;
  21.    using CadDb = Teigha.DatabaseServices;
  22.    using CadGe = Teigha.Geometry;
  23.    using CadEd = Bricscad.EditorInput;
  24.    using CadGi = Teigha.GraphicsInterface;
  25.    using CadClr = Teigha.Colors;
  26.    using CadWnd = Bricscad.Windows;
  27.  
  28. #elif AutoCAD
  29.    using Autodesk.AutoCAD.Runtime;
  30.    using Autodesk.AutoCAD.ApplicationServices;
  31.    using Autodesk.AutoCAD.DatabaseServices;
  32.    using Autodesk.AutoCAD.Geometry;
  33.    using Autodesk.AutoCAD.EditorInput;
  34.    using Autodesk.AutoCAD.GraphicsInterface;
  35.    using Autodesk.AutoCAD.Colors;
  36.    using Autodesk.AutoCAD.Windows;
  37.    using Autodesk.AutoCAD.Internal;
  38.    using CadRx = Autodesk.AutoCAD.Runtime;
  39.    using CadApp = Autodesk.AutoCAD.ApplicationServices.Application;
  40.    using CadAs = Autodesk.AutoCAD.ApplicationServices;    
  41.    using CadDb = Autodesk.AutoCAD.DatabaseServices;
  42.    using CadGe = Autodesk.AutoCAD.Geometry;
  43.    using CadEd = Autodesk.AutoCAD.EditorInput;
  44.    using CadGi = Autodesk.AutoCAD.GraphicsInterface;
  45.    using CadClr = Autodesk.AutoCAD.Colors;
  46.    using CadWnd = Autodesk.AutoCAD.Windows;
  47. #endif
  48.  
  49. [assembly: CommandClass(typeof(CsBrxMgd.Commands))]
  50. [assembly: ExtensionApplication(typeof(CsBrxMgd.Commands))]
  51.  
  52. namespace CsBrxMgd
  53. {
  54.    /// <summary>
  55.    /// Class Commands.
  56.    /// </summary>
  57.    /// <seealso cref="IExtensionApplication" />
  58.    public class Commands : IExtensionApplication
  59.    {
  60.        #region Public Methods
  61.  
  62.        /// <summary>
  63.        /// this is initialized when the application is loaded
  64.        /// </summary>
  65.        public void Initialize()
  66.        {
  67.            Document doc = CadApp.DocumentManager.MdiActiveDocument;
  68.            Editor ed = doc.Editor;
  69.            Database db = doc.Database;
  70.            ed.WriteMessage("\nCsBrxMgd sample is loaded...");
  71.        }
  72.  
  73.        /// <summary>
  74.        /// this is initialized when the application is terminated
  75.        /// </summary>
  76.        public void Terminate()
  77.        {
  78.            CadApp.ShowAlertDialog("The commands class is Terminated");
  79.        }
  80.  
  81.        [CommandMethod("CopyObjectsBetweenDatabases", CommandFlags.Session)]
  82.        public static void CopyObjectsBetweenDatabases()
  83.        {
  84.            string filePath = @"c:\users\kbrown\desktop\New Drawing.dwg";
  85.            Database destDb = new Database(false, true);
  86.            Database sourceDb = CadApp.DocumentManager.MdiActiveDocument.Database;
  87.            destDb.ReadDwgFile(@"c:\users\kbrown\desktop\CopyViews.dwt", FileOpenMode.OpenForReadAndWriteNoShare, false, null);
  88.            destDb.CloseInput(true);
  89.            string myFileName = (string)CadApp.GetSystemVariable("DWGNAME");
  90.            string myFilePath = (string)CadApp.GetSystemVariable("DWGPREFIX");
  91.            string _originalFile = Path.Combine(myFilePath, myFileName);
  92.            string blockName = Path.GetFileNameWithoutExtension(_originalFile);
  93.            ObjectId xrefId = destDb.AttachXref(_originalFile, blockName);
  94.            HostApplicationServices.WorkingDatabase = destDb;
  95.            BlockTableRecord destModelSpace;
  96.            ObjectIdCollection idCollection = new ObjectIdCollection();
  97.            using (Transaction tr = destDb.TransactionManager.StartTransaction())
  98.            {
  99.                using (BlockReference br = new BlockReference(Point3d.Origin, xrefId))
  100.                {
  101.                    br.SetDatabaseDefaults();
  102.                    br.Layer = "0";
  103.                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForWrite);
  104.                    string relativePath = MakeRelativePath(filePath, _originalFile);
  105.                    btr.PathName = relativePath;
  106.  
  107.                    BlockTable bt = (BlockTable)tr.GetObject(destDb.BlockTableId, OpenMode.ForRead);
  108.                    destModelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
  109.                    destModelSpace.AppendEntity(br);
  110.                    tr.AddNewlyCreatedDBObject(br, true);
  111.                }
  112.  
  113.                tr.Commit();
  114.            }
  115.  
  116.            HostApplicationServices.WorkingDatabase = sourceDb;
  117.  
  118.            using (Transaction tr = sourceDb.TransactionManager.StartTransaction())
  119.            {
  120.                ViewTable vt = (ViewTable)tr.GetObject(sourceDb.ViewTableId, OpenMode.ForRead);
  121.                foreach (ObjectId id in vt)
  122.                {
  123.                    idCollection.Add(id);
  124.                }
  125.  
  126.                tr.Commit();
  127.            }
  128.  
  129.            using (Transaction tr = destDb.TransactionManager.StartTransaction())
  130.            {
  131.                try
  132.                {
  133.                    BlockTable destBt = (BlockTable)tr.GetObject(destDb.BlockTableId, OpenMode.ForRead);
  134.                    destModelSpace = (BlockTableRecord)tr.GetObject(destBt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
  135.                    IdMapping mapping = new IdMapping();
  136.                    destDb.WblockCloneObjects(idCollection, destModelSpace.ObjectId, mapping, DuplicateRecordCloning.Ignore, false);
  137.                }
  138.                catch (Exception ex)
  139.                {
  140.                    MessageBox.Show($"Error in wblockclone:\n{ex.Message}");
  141.                }
  142.  
  143.                tr.Commit();
  144.            }
  145.  
  146.            destDb.SaveAs(filePath, DwgVersion.Current);
  147.  
  148.        }
  149.  
  150.        public static string MakeRelativePath(string fromPath, string toPath)
  151.        {
  152.            string relativePath = toPath;
  153.            try
  154.            {
  155.                Uri fromUri = new Uri(fromPath);
  156.                Uri toUri = new Uri(toPath);
  157.                if (fromUri.Scheme != toUri.Scheme)
  158.                {
  159.                    return toPath;
  160.                } // path can't be made relative.
  161.  
  162.                Uri relativeUri = fromUri.MakeRelativeUri(toUri);
  163.                relativePath = Uri.UnescapeDataString(relativeUri.ToString());
  164.                if (toUri.Scheme.ToUpperInvariant() == "FILE")
  165.                {
  166.                    relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
  167.                }
  168.            }
  169.            catch
  170.            {
  171.  
  172.            }
  173.  
  174.            return relativePath;
  175.        }
  176.  
  177.        #endregion Public Methods
  178.    }
  179. }
  180.  
7
CAD General / Re: AutoCAD in the browser... here we go..
« Last post by Atook on April 28, 2017, 01:54:50 pm »
As cadtag indicates, good bandwidth and caching will be key.

Marking up a cad dwg in the field could be as simple as adding notes, which could certainly be useful in the field and the office. Working on a dwg instead of a PDF takes another layer of complexity out of the equation. Who knows where it will go from there. Back in the day we accessed email/communications through programs on a desktop computer. I've got friends and family members who only use a smart phone .

Google Earth is a good example, though it highlights the problem of bandwidth limiting user experience. The desktop app had the same limitations.

If you run the backend on a powerful CAD station server, then AutoCAD starts to be available to all kinds of users, with all kinds of licensing possibilities. The interface would need some work, even running CAD through an RDP connection on my local network feels like I've had one G&T too many.  :-D
8
AutoLISP (Vanilla / Visual) / Re: Make (entlast) work like (entsel)
« Last post by GDF on April 28, 2017, 01:45:47 pm »
Here is what I got to work:

Code: [Select]
(defun C:WW2  ()
  (ARCH:F_S-VAR)
  (defun ARCH:MIDPOINT  (w z)
    (list (/ (+ (car w) (car z)) 2) (/ (+ (cadr w) (cadr z)) 2)))
  (ARCH:LYR "A-WALL-FULL")
  (setq pt1 (getpoint "\n* Pick beginning point *"))
  (setq pt2 (getpoint pt1 "\n* Pick the end point *"))
  (command "line" pt1 pt2 "")
  (setq mid (ARCH:MIDPOINT pt1 pt2))
  (defun lastline ( / s )
    (if (setq s (ssget "_X" '((0 . "LINE"))))(ssname s 0)) 
  )
  (entget (entlast))
  (setq wallline     (list (lastline) mid) ;;(entsel "\n* Select Line to offset...")
        firstendpnt  (trans (cdr (assoc 10 (entget (car wallline)))) 0 1)
        secondendpnt (trans (cdr (assoc 11 (entget (car wallline)))) 0 1)
        pnt2         (getpoint "\n* Specify Offset Directiont --> ")
        ang1         (angle firstendpnt secondendpnt)) 
  (if (and (> ang1 (/ pi 2.0)) (<= ang1 (* pi 1.5)))
    (setq ang1 (+ ang1 pi))) 
  (command "offset" "3.5" wallline pnt2 "")
  (command "change" "l" "" "p" "la" "A-WALL-FULL" "")
  (ARCH:LYR "A-WALL-VENR")
  (command "offset" "9.0" wallline pnt2 "")
  (command "change" "l" "" "p" "la" "A-WALL-EXT" "")
  (princ)
  (ARCH:F_R-VAR)
  (princ))

Thanks Lee
9
CAD General / Re: AutoCAD in the browser... here we go..
« Last post by cadtag on April 28, 2017, 01:31:15 pm »
If there's sufficient bandwidth/speed... why not?  whether you work on files stored on a LAN, a WAN, or local disk, the actual editing is happening on an in-memory / locally cached copy of the actual dwg.  Only Saves write back to the original.
10
AutoLISP (Vanilla / Visual) / Re: Make (entlast) work like (entsel)
« Last post by Lee Mac on April 28, 2017, 01:09:02 pm »
(lastline) is the same as (entlast)

No it's not.
Pages: [1] 2 3 ... 10