Text Window Access thru VBA

Text Window Access thru VBA

Anonymous
Not applicable
2,160 Views
14 Replies
Message 1 of 15

Text Window Access thru VBA

Anonymous
Not applicable
I would like to know if there is a way to access either the command line or the text window through Visual Basic other than the SendCommand method. I would like to post a comment to the command line area and not to a popup dialog box as MsgBox does.
0 Likes
2,161 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable
ThisDrawing.Utility.Prompt "My Message to display goes here"

Will display the message at the command prompt but not pause for user input. You also need CMDECHO to be ON.
0 Likes
Message 3 of 15

Anonymous
Not applicable
Thanks!! It really works!!!
0 Likes
Message 4 of 15

Anonymous
Not applicable
If you want to make it look like the Command: prompt is clear, use ThisDrawing.Utility.Prompt "my message" & vbCrLf & "Command:" HTH, Ed
0 Likes
Message 5 of 15

Anonymous
Not applicable
Thank you. That will come in very handy!
0 Likes
Message 6 of 15

brian_adams
Collaborator
Collaborator

Is there way to capture text from Autocad text window or command line?

0 Likes
Message 7 of 15

norman.yuan
Mentor
Mentor

No, not with AutoCAD VBA/COM APIs, AFAIK.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 8 of 15

brian_adams
Collaborator
Collaborator
0 Likes
Message 9 of 15

Ed__Jobe
Mentor
Mentor

Even if you could, those api's don't apply to AutoCAD's command line.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 10 of 15

brian_adams
Collaborator
Collaborator

Could it be sollution???

 

https://forums.autodesk.com/t5/visual-basic-customization/capturing-command-line-output-from-vba/m-p...

 

I missed some thing it capture emptyness

0 Likes
Message 11 of 15

Ed__Jobe
Mentor
Mentor

No, that just writes the output of a command to the system variable USERS1.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 12 of 15

brian_adams
Collaborator
Collaborator

There is some macros that  can capture a lot of things. they works

 

https://stackoverflow.com/questions/2784367/capture-output-value-from-a-shell-command-in-vba

but any example of text window in AutoCAD

 

0 Likes
Message 13 of 15

Ed__Jobe
Mentor
Mentor

As @norman.yuan already mentioned, not for AutoCAD VBA.

 

You never stated what you're trying to do. Why do you need to capture the command window text? Perhaps there is an alternative?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 14 of 15

brian_adams
Collaborator
Collaborator

oh this is dream

I want to make material report for AECobject in Autocad Architecture

The only method to calculate  fine is command "Materiallist"

I've made is macro that 

1. makes property set deffinition for (AECwall) 

2.creates property"material" 

3. serching for AECwall in current drawing

4. select it and  run materiallist command for every AECwall
5. MiSSED PART(capture value from command line and filtering it) but filtering not a problam
6. wright it to property

I made chek wrighting ID of every AECwall to property"material"  it works

so there is  another way only I see now

Manually  copy history of autocad window text and copy it to excel file


then  run another script to capture date   and apply it to AECwall

 

 

that how it looks now

 

 

Sub materiallist()

Dim SchedApp As New AecScheduleApplication
Dim cProps As AecScheduleProperties
Dim PropSetDefs As AecSchedulePropertySetDefs
Dim propsetdef As AecSchedulePropertySetDef
Dim propertyDefs As AecSchedulePropertyDefs
Dim propertydef As AecSchedulePropertyDef
Dim propertyset As AecSchedulePropertySet
Dim propertysets As AecSchedulePropertySets
Dim obj As AcadObject
Dim msg As String
Dim PrSetDefName As String
Dim propertydefname As String

PrSetDefName = "Wall_Materiallist"
propertydefname = "Materiall"
'_______________________________create property set________________________________
On Error Resume Next
' Access the set of property definitions.
Set propsetdef = PropSetDefs(PrSetDefName)
' If set of property definitions isn't created then create it.
If propsetdef Is Nothing Then
PropSetDefs.Add (PrSetDefName)
Set PropSetDefs = SchedApp.PropertySetDefs(ThisDrawing.Database)
Set propsetdef = PropSetDefs(PrSetDefName)
End If

' Now add a property definition to the new set of definitions.
Set propertyDefs = propsetdef.propertyDefs
On Error Resume Next
Set propertydef = propertyDefs(propertydefname)
' If set of property definitions name isn't created then create it.
If propertydef Is Nothing Then
propertyDefs.Add (propertydefname)
Set propertydef = propertyDefs(propertydefname)
End If

' Access the definition just created, and set some properties.
Set propertydef = propertyDefs(propertydefname)
propertydef.Description = "materiall from materiallst."
propertydef.Format = "Standard"
propertydef.Type = aecSchedulePropertyTypeText

'_________________________________counting materiallist______________________________________

Dim ent As AcadEntity
Dim geo As AecGeo
Dim wall As AecWall
Dim findObj As AcadObject
Dim point(0 To 2) As Double
Dim sset As AcadSelectionSet

For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AecWall Then
Set wall = ent
Set sset = ThisDrawing.SelectionSets.Add("SS10")
ObjectID = wall.ObjectID
Set findObj = ThisDrawing.ObjectIdToObject(ObjectID)
point(0) = wall.Location(0): point(1) = wall.Location(1): point(2) = wall.Location(2)

sset.SelectAtPoint point
If sset.Count > 0 Then
ThisDrawing.Utility.Prompt "ID " & ObjectID
ThisDrawing.SendCommand "Select p " & vbCrLf
ThisDrawing.SendCommand "Materiallist" & vbCr & vbCr


ThisDrawing.Utility.Prompt "ID " & ObjectID

'________________apply property to walls _____________________
Set propertysets = SchedApp.propertysets(wall)
' Add a new property set. Notice that the Add method requires
' a property set definition argument, not a property set.
propertysets.Add propsetdef
'___________________________adding value to property set and_____________________

Dim retval As String
retval = CStr(ObjectID)
Set propertysets = SchedApp.propertysets(wall)
On Error Resume Next
Set propertyset = propertysets.Item("Wall_Materiallist")
If Not propSet Is Nothing Then
Set cProps = propertyset.Properties
cProps.Item("Materiall").Value = retval
ThisDrawing.SelectionSets("SS10").Delete
End If
End If
Else
Set ent = Nothing

End If
Next

End Sub

 

 

 

 

0 Likes
Message 15 of 15

brian_adams
Collaborator
Collaborator
0 Likes