Recent Posts

Pages: [1] 2 3 ... 10
AutoLISP (Vanilla / Visual) / How to modify strings in FAS files
« Last post by baitang36 on Today at 03:40:36 AM »
This is my first post.
2 other takers?
AutoLISP (Vanilla / Visual) / Re: One Line Diagram via copy F1
« Last post by tfpacad19 on January 21, 2019, 04:38:24 PM »

It has been a long time since I visited this one line topic.

Is there a way to modify the one line routine to utilize the "true" block name? I am using annotative/dynamic blocks now and the routine crashes when it encounters an anonymous block name.

I know this is a very old topic, I have started another job where I am utilizing this again.

Any help is appreciated.

.NET / Re: Update attribute in sideDatabase (AutoCAD 2019)
« Last post by Jeff_M on January 21, 2019, 10:25:10 AM »
Change this:
targetDb.ReadDwgFile(FilePath, System.IO.FileShare.ReadWrite, True, "")

to this:
targetDb.ReadDwgFile(FilePath, FileOpenMode.OpenForReadAndWriteNoShare, True, "")
.NET / Update attribute in sideDatabase (AutoCAD 2019)
« Last post by djee on January 21, 2019, 09:57:47 AM »
This code does not work anymore on AutoCAD 2019. I'm targeting the Framework 4.7. The managed .NET Reference guide specified that the function
Code: [Select]
Database.ReadDwgFile(string, FileShare, [MarshalAs(UnmanagedType.U1)] bool, string) Method is obsolete & will be remove in future release. When debugging, It does not iterate through the object ID's in the BlockTableRecord? Could the function have been replace? I'm looking into the Graphic system changes... But any input would be nice...

Code: [Select]
Public Shared Sub UpdateAttributesInSideDatabase(ByVal FilePath As String, blockName As String, attbName As String, attbValue As String)
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim currentDb As Database = doc.Database
        Dim ed As Editor = doc.Editor

        Using targetDb As New Database(False, True)
                targetDb.ReadDwgFile(FilePath, System.IO.FileShare.ReadWrite, True, "")
                Using tr As Transaction = targetDb.TransactionManager.StartTransaction()
                    Dim layoutDict As DBDictionary = tr.GetObject(targetDb.LayoutDictionaryId, OpenMode.ForRead)
                    For Each dicEnt As DBDictionaryEntry In layoutDict
                        Dim lay As Layout = DirectCast(dicEnt.Value.GetObject(OpenMode.ForRead), Layout)
                        ''do your stuffs in every layout
                        If lay.LayoutName <> "Model" Then
                            Dim btr As BlockTableRecord = tr.GetObject(lay.BlockTableRecordId, OpenMode.ForRead)
                            For Each id As ObjectId In btr
                                If id.ObjectClass.DxfName = "INSERT" Then
                                    Dim br As BlockReference = DirectCast(tr.GetObject(id, OpenMode.ForRead), BlockReference)
                                    ' ... to see whether it's a block with
                                    ' the name we're after

                                    If br.Name.ToUpper() = blockName.ToUpper() Then
                                        For Each arId As ObjectId In br.AttributeCollection
                                            Dim ar As AttributeReference = DirectCast(tr.GetObject(arId, OpenMode.ForRead), AttributeReference)
                                            ' ... to see whether it has
                                            ' the tag we're after

                                            If ar.Tag.ToUpper() = attbName.ToUpper() Then
                                                ' If so, update the value
                                                ' and increment the counter

                                                ar.TextString = attbValue
                                                'realign attributes after editing their values

                                            End If
                                    End If
                                End If
                        End If
                    'end of code from template insert
                End Using

                targetDb.SaveAs(FilePath, DwgVersion.Current)
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                ed.WriteMessage(vbLf & "Error while running > " + ex.Message)
            End Try
        End Using
    End Sub
AutoLISP (Vanilla / Visual) / Creating a rectangle with the same area
« Last post by dussla on January 21, 2019, 03:44:52 AM »

always thank you again

i  finding this  lisp

1. i made rectangle

2.  i stretched that

3. but  when  i  streched that   ,   I want to keep the same area when that  changeed the shape

i seen this lisp here
but i can not find  again

AutoLISP (Vanilla / Visual) / Re: Deduct Dates in Autolisp
« Last post by Bilal on January 19, 2019, 08:22:46 AM »
Thank you Lee Mac.
AutoLISP (Vanilla / Visual) / Re: Deduct Dates in Autolisp
« Last post by Lee Mac on January 19, 2019, 08:01:51 AM »
Convert the dates to Julian then subtract, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (defun daydiff ( d1 d2 )
  2.    (- (fix (dtoj d2)) (fix (dtoj d1)))
  3. )
Code - Auto/Visual Lisp: [Select]
  1. _$ (daydiff 20190117 (getvar 'cdate))
  2. 2
  3. _$ (daydiff 20181219 (getvar 'cdate))
  4. 31

(dtoj is part of Julian.lsp included with Express Tools)

Note that the DATE system variable returns a Julian date already, so if you simply want the difference from the current date, the code may be:
Code - Auto/Visual Lisp: [Select]
  1. (defun daydiffnow ( d1 )
  2.    (- (fix (getvar 'date)) (fix (dtoj d1)))
  3. )
Code - Auto/Visual Lisp: [Select]
  1. _$ (daydiffnow 20190117)
  2. 2
AutoLISP (Vanilla / Visual) / Deduct Dates in Autolisp
« Last post by Bilal on January 19, 2019, 07:35:15 AM »
Hi Guys,

Is there an AutoLISP routine to deduct two dates and get the results in days
for example: last date is  "19750225"  year 1975 month 02 day 25 and the current date is (rtos (getvar "cdate") 2 0)
The question is how to get the exact days between this 2 dates in autolisp.

AutoLISP (Vanilla / Visual) / Re: Strange behavior function GC:INTERSECT
« Last post by Giuseppe Beatrice on January 19, 2019, 06:23:06 AM »
Thank you Lee, you are my best master.
Pages: [1] 2 3 ... 10