Quantcast
Channel: Autodesk India Community aggregator
Viewing all 1680 articles
Browse latest View live

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Mtext Height issue

$
0
0

Hi all,

 

I am working on a simple function to add/remove a non-printing stamp our drawings to specify a preliminary drawing. The issue is that I cannot seem to get AutoCAD to accept the text height in the Mtext command. Below is the code; try it and see.

(DEFUN NOT4CONSTRUCTION	(/ CTR HGT PT1 PT2)
  (IF (EQ (GETVAR "CLAYER") "NOT4CONSTRUCTION") (SETVAR "CLAYER" "0"))
  (IF (EQ (GETVAR "CTAB") "MODEL") (SETQ HGT "8'-4\"") (SETQ HGT "1\""))
  (IF (= (ASSOC 0 (TBLSEARCH "layer" "NOT4CONSTRUCTION")) nil)
    (PROGN
      (VL-CMDF "-LAYER" "M" "NOT4CONSTRUCTION" "C" "30" "" "TR" 90 "" "P" "N" "" "")
      (SETQ PT1	(LIST (- (CAR (GETVAR "viewctr"))
			 (/ (* (GETVAR "viewsize") (/ (CAR (GETVAR "screensize")) (CADR (GETVAR "screensize")))) 2)
		      )
		      (- (CADR (GETVAR "viewctr")) (/ (GETVAR "viewsize") 2))
		      0
		)
	    PT2	(LIST (+ (CAR (GETVAR "viewctr"))
			 (/ (* (GETVAR "viewsize") (/ (CAR (GETVAR "screensize")) (CADR (GETVAR "screensize")))) 2)
		      )
		      (+ (CADR (GETVAR "viewctr")) (/ (GETVAR "viewsize") 2))
		      0
		)
	    CTR	(MAPCAR '/ (MAPCAR '+ PT1 PT2) '(2 2 2))
      )
      (vl-cmdf "_.mtext" CTR "H" HGT "J" "MC" "S" "DesignStudio" "W" "30" "PRELIMINARY" "NOT FOR CONSTRUCTION" "")
    )
    (VL-CMDF "-LAYDEL" "N" "NOT4CONSTRUCTION" "" "Y")
  )
  (PRINC)
)

 Please, if you can, help.

 

BTW- I'm on AC2013 if that makes a difference.


AutoCAD Customization: .NET: Nested block position in model/paper space.

$
0
0

Hi,  I need to gather objects on a specivied layername within model_space in C#.

 

How do I add a fileter to my filtervalues to only grab model_space objects.

 

 

TypedValue

[] filterValues = new[] { newTypedValue((int)DxfCode.LayerName, LayerName.ToUpper()) };

SelectionFilter filter = newSelectionFilter(filterValues);

PromptSelectionResult foundBlocks = this.ed.SelectAll(filter);

SelectionSet currSS = foundBlocks.Value;

 

or

 

how to I check after I get the object and check the blockname

 

currEnt = (Entity)objID.GetObject(OpenMode.ForWrite);

                           

if (currEnt.BlockName != "*Model_Space")

 

Please if someone could give me some guidence with the syntax.

 

thanks

AutoCAD Customization: .NET: Movement in rotated UCS, 2D.

$
0
0

Hello forum,

 

I have a width. I want to move an object along the x-axis, with this width. No problem. But when the UCS is rotated, it still moves the object along the original x-axis.

How do I move the object along the x-axis of the rotated UCS?

 

Movement along the z-axis will always be 0 (2D only).

 

Thank you.

 

 

 

 

AutoCAD Customization: .NET: Changing MLeaderStyle - annotation scale.

$
0
0

Hello Forum,

 

I have code that changes the MLeaderStyle property of a MLeader object.

When I run the code, the current annotation scale is added to the MLeader and set as current. I don't want this to happen, but this happens automatically.

 

Any idea what could cause this?

 

Code:

 

MLeader objMLeader;
DBDictionary dbdMLStyles;
string strMLeaderStyleNew;
...
objMLeader.UpgradeOpen();
objMLeader.MLeaderStyle = (ObjectId)dbdMLStyles[strMLeaderStyleNew];
objMLeader.DowngradeOpen();

 

Thank you.

 

 

AutoCAD Customization: .NET: Save as problem - pls help

$
0
0

I have some files path store in a string[] variable. I want open each file and send string to execute, like as draw a line in drawing. Then save, close drawing and continue to another file. This is my code:

 

        [CommandMethod("send")]

        public static void test()

        {

            string Command = "(Command \".Line\" '(0 0) '(0 10) \"\") ";

            string[] Files = new string[3];

            Files[0] = "C:\\test1.dwg";

            Files[1] = "C:\\test2.dwg";

            Files[2] = "C:\\test3.dwg";

            foreach (string fil in Files)

            {

                if (System.IO.File.Exists(fil) == true)

                {

                    DocumentCollection acDocMgr = Application.DocumentManager;

                    Document acDoc = acDocMgr.MdiActiveDocument;

                    try

                    {

                        acDoc = acDocMgr.Open(fil, false);

                        using (DocumentLock DcLck = acDoc.LockDocument())

                        {

                            using (Transaction acTrans = acDoc.Database.TransactionManager.StartTransaction())

                            {

                                acDoc.SendStringToExecute(Command, true, false, false);

                                acDoc.Database.SaveAs(acDoc.Name, true, DwgVersion.Current, acDoc.Database.SecurityParameters);

                                acTrans.Commit();

                            }

                        }

                        acDoc.CloseAndSave(fil);

                    }

                    catch (Autodesk.AutoCAD.Runtime.Exception ex)

                    {

                        acDoc.Editor.WriteMessage("Error: " + ex.ToString());

                    }

                }

            }

        }

 

But it had error at Save as line. Please help!

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: vlax-acSp

$
0
0

what is acSp in below mentioned code line

 

(setq Xline (vlax-invoke acSp 'AddXLine startPt endPt))

I have downloaded a lisp from here

And while running this lisp routine the program fails at above mentioned line.

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Unreconciled Layer Filter

$
0
0

Hi

 

Does anyone know how to automate the unreconciled layer list to automatically freeze all the layers in the list when opening drawing.  This would force the user to select what layers they want shown rather than freezing / turning off the layers they don't want.

 

Thanks

 

Steve

AutoCAD Customization: .NET: Help! Importing .DWG Files in Inventor Doesn't Work For Me

$
0
0

Can anyone help me how to compare two AutoCAD drawing using .NET API :

 

The comparison will be done as mentioned below factors:

 

1. Any type Entity

2. Block Reference
etc.

 

Becuase I want to make my own dwg comparator which will comapre two folder with all the possible features.

 

Thanks in Advance...


AutoCAD Customization: Visual LISP, AutoLISP and General Customization: How I can make Lisp function for SELECTED ALL object in the drawing ?

$
0
0

Does anybody know lisp code ?

How to make alispcommand that willselectall objects in thedrawing?

 

 

AutoCAD Customization: .NET: Help! Compare drawings

$
0
0

Can anyone help me how to compare two AutoCAD drawing using .NET API :

 

The comparison will be done as mentioned below factors:

 

1. Any type Entity

2. Block Reference
etc.

 

Becuase I want to make my own dwg comparator which will comapre two folder with all the possible features.

 

Thanks in Advance...

 

 

Edited by
Discussion_Admin

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: VLIDE starting directory

$
0
0

Say you launch AutoCAD, then run VLIDE.

Then from inside the VLIDE, you go File>Open.....it seems to default to a different, random directory every time. I know there has to be some logic to it, and I want to set the default location, so I do not have to browse every time.

 

Years ago, I seem to remember someone saying how to set this starting directory, I just can't find that now.

 

Anyone?

TIA

AutoCAD Customization: .NET: C3D 2014 Problem with Surface Analysis

$
0
0

What is changed about setting user defined contours, contourdata and elevationdata to a TinSurface in C3D 2014?

When we use the same code that works fine in C3D 2013, we don't get errors but it just don't seems to work???

 

This is the code that doesn't work:

For i = 0 To UBound(srf_contours)
	Dim xmin As Double = ana_elev.Rows(i).Cells(1).Value 'Minimum van de zone
	Dim xmax As Double = ana_elev.Rows(i).Cells(0).Value 'Maximum van de zone
	Dim frmcol As Drawing.Color = ana_elev.Rows(i).Cells(2).Style.BackColor
	'Dbug(xmin & " - " & xmax & " : RGB(" & frmcol.R & "," & frmcol.G & "," & frmcol.B & ")")
	Dim xcol As Autodesk.AutoCAD.Colors.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(frmcol.R, frmcol.G, frmcol.B)
	srf_contours(i) = New SurfaceAnalysisContourData(xmin, xmax, z1)
	srf_elevation(i) = New SurfaceAnalysisElevationData(xmin, xmax, xcol)
Next

csurf.Analysis.SetContourData(srf_contours)
csurf.Analysis.SetElevationData(srf_elevation)

 When we get the Data back in the same transaction "csurf.Analysis.GetContourData" we get the correct data back.

After a tr.commit() it seems that the data we've set is lost?

 

Regards,

 

Peter

 

AutoCAD Customization: Autodesk ObjectARX: sort the order of the scales using ARXDBG tool

$
0
0

Hi,

 

I want to  sort the order of the scales in the list (like the move up/down option in the scale list dialog) using ARXDBG tool.

 

Is there any possible way?

 

Regards,

 

Arul.

AutoCAD Customization: .NET: ADN Product Download

$
0
0

New to the Autodesk ADN.  I was wondering if I can use my existing product downloads (such as AutoCAD or Building Design Suite Premium) and just plug in my ADN serial number/product key or do I need to redownload the same products again from the ADN site.  Would be easier to use the same product downloads, but I can see where there might be a separate build tied to the ADN info.

 

I appreciate your help in advance.

 

Dave

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: Dynamic Block -Accessing Action Parameters - Tutorials

$
0
0

I have a new project coming up where I need to write some simple programs to access the dynamic action parameters in some existing dynamic blocks.

I have viewed what I could find on AU, but I still ave not found anything relating in-depth to dynamic blocks. 

 

Does anyone know of any good Tutorials, Articles, or White Papers, on  working with dynamic blocks with autolisp/ vlisp?  The main fuction is to access a parameter and change it by entering a numeric value, updating the block. say from a linear/polar stretch, or a linear/ polar move.

 

Any suggestions are appreciated. 

 

Thanks;

 AutoCAD 2012 

 

 


AutoCAD Customization: .NET: Problem regarding Modeless form

$
0
0

Hi ,

 

I got one problem while using a modeless form. In a modeless form , I simply put a button and the button event is  like below code:

 

Private

Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

 

Dim acDoc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

acDoc.Editor.Regen()

EndSub

 

Then I got the output:

 

Capture12.JPG

 

output is okay. It will be 'Regenerating model'. But my question is why it is coming with 'command:'. While using the same code with modal then output only show 'Regenerating model' and 'command:' is not appear with that.

 

Capture12.JPG

 

It would be great if anybody explain me the problem and tell me how to get rid of it.

 

Thanks  and Regards

Zakir

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: GetAttributes via lisp

$
0
0

Hello guys,

 

         I am trying to find a lisp that would get an attribute value (tag name = NBR_5) . I'm trying to run a simple routine that would let the user place the value from the titleblock attribute as text on a drawing. I see a ton of articles regarding getting attributes but I am not well versed in programming.

 

Any help is greatly appreciated. 

 

Thanks in advance. 

 

AutoCAD Customization: Visual LISP, AutoLISP and General Customization: looping through results

$
0
0

This may be a little complicated to explain what I want But I will do my best.  I wrote a lisp, that grabs all text and assigns it a variable. Here's what it looks like:

 

(setq numbers (ssget "_X" (list (cons 0 "TEXT") (cons 1 "*")) ))
(sslength numbers)  
  (setq numb1(ssname numbers 0))
    (setq enlist1 (entget numb1))
    (setq texty (fix (caddr(assoc 10 enlist1))))
    (setq value1 (cdr(assoc 1 enlist1)))

 

In this case sslength returns a value of 20.  I can repeat this command 20 times and have all these variables but I don't think that is the best way.  I do need the "y" value insertion point of the text.  Line numbers are very important with what I do.

 

In the end what I want to do is

1.   sort through how ever many values sslength returns.

2.  compare a blocks attribute "y" value insertion point with that of all the text values.

3.  If both y values are equal then that blocks "tag name" will be changed.

 

Here is what I am doing on the block end with for reference:

 

(if (= texty fuwhole)
(setq funum1 (subst (cons 1 (strcat "FU" value1)) (assoc 1 funum1) funum1))
(entmod funum1)
)

 

fuwhole is the blocks "y" value insertion point.

funum1 is the blocks dxf group code

 

Any Ideas?

 

Thanks,

 

AutoCAD Customization: Visual Basic Customization: program won't work in 2013

$
0
0

Hi,

This program worked fine in 2010, haven't used it since. Installed VBA 2013 64 bit. Get error can not create Actice X.

 

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop.Common


Public Class Form1
    Public strFile As String
    Public strRet1, strRet2, strRet3, strRet4, strRet5 As String
    Private strItem As String

    Private Sub OpenBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenBtn.Click
        'browse for file
        Dim openFileDialog1 As New OpenFileDialog()
        openFileDialog1.InitialDirectory = "c:\"
        openFileDialog1.Filter = "txt files (*.txt)|*.txt|csv files (*.csv)|*.csv"
        openFileDialog1.FilterIndex = 2
        openFileDialog1.RestoreDirectory = True
        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            strFile = openFileDialog1.FileName
        End If

        'read file and insert images

        Dim fileNameIV As String = strFile
        Dim objWordReader As System.IO.StreamReader
        Dim strLine, Delimiter As String

        If System.IO.File.Exists(fileNameIV) = True Then
            objWordReader = System.IO.File.OpenText(fileNameIV)
            Do Until objWordReader.Peek = -1
                Delimiter = ","
                strLine = objWordReader.ReadLine()
                ListBox1.Items.Add(strLine)

            Loop
            objWordReader.Close()
        End If
        Dim x As Integer
        For x = 1 To ListBox1.Items.Count - 1
            strItem = ListBox1.Items(x)
            ListBox1.Items.Add(strItem)


            Delimiter = ","
            Dim count As Integer
            Dim splitout As Object = Split(strItem, Delimiter)
            For count = 0 To UBound(splitout)

                Select Case count
                    Case 0      'point number
                        strRet1 = splitout(count)

                    Case 1      ' x
                        strRet2 = splitout(count)
                        strRet2 = Val(strRet2.TrimEnd("'"))

                    Case 2      ' y
                        strRet3 = splitout(count)
                        strRet3 = Val(strRet3.TrimEnd("'"))

                    Case 3      ' z
                        strRet4 = splitout(count)
                        strRet4 = Val(strRet4.TrimEnd("'"))

                    Case 4      ' discription

                        strRet5 = splitout(count)


                End Select
            Next

            Dim AcadApp As Autodesk.AutoCAD.Interop.Common.AcadRegisteredApplication
            Dim acaddoc As Autodesk.AutoCAD.Interop.Common.AxDbDocument
            Dim Pnt(0 To 2) As Double
            Dim nPnt(0 To 2) As Double
            Dim elPnt(0 To 2) As Double

            AcadApp = GetObject(, "Autocad.Application")
            acaddoc = AcadApp.ActiveDocument

            Pnt(0) = System.Convert.ToDouble(strRet2 * 12)

            Pnt(1) = System.Convert.ToDouble(strRet3 * 12)

            Pnt(2) = System.Convert.ToDouble(strRet4 * 12)

            nPnt(0) = System.Convert.ToDouble(strRet2 * 12)

            nPnt(1) = System.Convert.ToDouble(strRet3 * 12 + 10)

            nPnt(2) = 0

            elPnt(0) = System.Convert.ToDouble(strRet2 * 12 + 10)

            elPnt(1) = System.Convert.ToDouble(strRet3 * 12 + 25)

            elPnt(2) = 0

            If strRet5 = "TC" Then GoTo jump1
            If strRet5 = "BC" Then GoTo jump2
            If strRet5 = "Disc" Then GoTo jump2
            If strRet4 = 0 Then GoTo jump2
jump1:
            ''Dim Points, Label, Elev As String
            'Dim layer As AcadApp.layer
            acaddoc.ModelSpace.AddPoint(Pnt)

            'AcadApp.setlayer("Points")
            acaddoc.ModelSpace.AddText(strRet1, nPnt, 10)
            'AcadApp.setlayer("Label")
            acaddoc.ModelSpace.AddText(strRet4 & "'", elPnt, 10)
            ' AcadApp.setlayer("Elev")
jump2:
        Next
    End Sub
   
End Class

 

 Thank you

Bob v

AutoCAD Customization: .NET: Modify Dynamic Block Properties before Jig

$
0
0

Hi, 

 

Is there a way to modify the properties of a dynamic block after the insert and before a jig?

 

I've tried a quite a few things but here is some code as a starting point. The blocks are affected by the change but not in a good way. The blocks have several parametric constraints. I wonder if this is part of the problem.

 

<CommandMethod("TestEntityJigger7")> _
    Public Shared Sub TestEntityJigger7_Method()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Dim pr As PromptResult = ed.GetString(vbLf & "Block name:")
        If pr.Status = PromptStatus.OK Then
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim btr As BlockTableRecord = TryCast(tr.GetObject(bt(pr.StringResult), OpenMode.ForRead), BlockTableRecord)
                If btr IsNot Nothing Then
                    Dim br As New BlockReference(New Point3d(0, 0, 0), btr.ObjectId)
                    Dim pc As DynamicBlockReferencePropertyCollection = br.DynamicBlockReferencePropertyCollection
                    For i = 0 To pc.Count - 1
                        Dim prop As DynamicBlockReferenceProperty = pc(i)
                        If prop.PropertyName = "A" Then prop.Value = 1000.0#
                        If prop.PropertyName = "B" Then prop.Value = 2000.0#
                    Next
                    pc.Dispose()
                    If BlockMovingRotating.Jig(br) Then
                        Dim modelspace As BlockTableRecord = TryCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                        modelspace.AppendEntity(br)
                        tr.AddNewlyCreatedDBObject(br, True)
                        tr.Commit()
                    Else
                        tr.Abort()
                    End If
                End If
            End Using
        End If
    End Sub

 

Viewing all 1680 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>