VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I use the commands in macro .

4 REPLIES 4
Reply
Message 1 of 5
contar
372 Views, 4 Replies

How can I use the commands in macro .

How can I use the commands in macro .

4 REPLIES 4
Message 2 of 5
adam.nagy
in reply to: contar

Hi,

 

I think you would need to be a bit more specific. 🙂 What exactly would you like to do?

Are you trying to run a command from VBA?

 

For that you can use SendCommand() - e.g. SendCommand("_LINE 0,0,0 10,10,0 ")

 

I hope this helps.

 

Cheers,

Adam Nagy

Autodesk Developer Network



Adam Nagy
Autodesk Platform Services
Message 3 of 5
contar
in reply to: contar

For example, I want to run in the macro Area command.
1)When I run the macro, asks area of corner points
2) when I choose the points , asks to write where the measured field
3) when I choose the points where write the area, value of area is written there.

I hope, I can describe.

Message 4 of 5
Hallex
in reply to: contar

Not sure  what you mean about command in macro,

here is just very basic example:

{code}

Option Explicit
Sub TestArea()
    ' Define points
    Dim Pnt1, Pnt2, Ptxt
   
    ' Return a point using a prompt
    Pnt1 = ThisDrawing.Utility.GetPoint(, "Specify first corner point: ")

    ' Prompt the user to pick second point and returns the point
    Pnt2 = ThisDrawing.Utility.GetCorner(Pnt1, "Specify other corner point: ")
   
    ' Prompt the user to pick text point and returns the point
    Ptxt = ThisDrawing.Utility.GetPoint(, "Specify middle point of text: ")
   
    ' Get width and height of specified rectangle
    Dim dblWidth As Double
    dblWidth = Abs(CDbl(Pnt1(0)) - CDbl(Pnt2(0)))
    Dim dblHeight As Double
    dblHeight = Abs(CDbl(Pnt1(1)) - CDbl(Pnt2(1)))
   
    ' Calculate an area
    Dim dblArea As Double
    dblArea = dblWidth * dblHeight
   
    Dim intPrec As Integer
    ' Prompt the user to specify precision and return number of decimal places
   intPrec = CInt(InputBox("Enter a number of decimals:", "Area Label", 3))
  
   Dim strArea As String
   ' Convert a real value of 'dblArea' using Decimal mode to a String

  strArea = ThisDrawing.Utility.RealToString(dblArea, acDecimal, intPrec)
  Dim txtHeight As Double
 
  ' Get the currrent dimension style text height
  txtHeight = ThisDrawing.GetVariable("Dimtxt")
 
  ' Create the text object in the current space
  Dim oText As AcadText
  Set oText = ThisDrawing.ActiveLayout.Block.AddText(strArea, Ptxt, txtHeight)
 
    ' Change the value of the HorizontalAlignment and
    ' TextAlignmentPoint properties.
  oText.HorizontalAlignment = acHorizontalAlignmentCenter
  oText.Alignment = acAlignmentMiddleCenter
  oText.TextAlignmentPoint = Ptxt
End Sub

{code}

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 5
Hallex
in reply to: contar

See attachment

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost