Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swaping properties 1

Status
Not open for further replies.

FAM

Technical User
Jan 13, 2003
345
0
0
GB
In the properties panel of a text layer, is it possible to copy the value of the contents box (Text-SubMenu) in each entity, into the Position Z (Geometry-SubMenu) box for the whole layer?
As i have thousands of points & i dont want to do it manually.

Thanks.
 
If you happen to have Autodesk Map this is out-of-the-box functionality. If you do not, I have a VBA macro you can use. It doesn't look like I can post the dvb in this newsgroup - so here is the code. In acad type vbaide and paste this code into the ThisDrawing section - change the Layer name to reflect your layer name and run it.

Code:
Option Explicit

Sub editZ()
  Dim ss As AcadSelectionSet
  Dim objText As AcadText
  Dim alignmentPoint(0 To 2) As Double
  Dim intCnt As Integer
  Dim intSkipped As Integer
  Dim FilterType(1) As Integer
  Dim FilterData(1)

    FilterType(0) = 0: FilterData(0) = "TEXT" 'Object to filter
    FilterType(1) = 8: FilterData(1) = "TestLayer" '<<[COLOR=red]Change Layer Name to filter[/color]

    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets.Add("s")
    If Err Then
      ThisDrawing.SelectionSets.Item("s").Delete
      Set ss = ThisDrawing.SelectionSets.Add("s")
      Err.Clear
    End If
    
    On Error GoTo errHandler
    ss.Select acSelectionSetAll, , , FilterType, FilterData
    
    For Each objText In ss
      If IsNumeric(objText.TextString) Then
        Select Case objText.Alignment
          Case acAlignmentLeft, acAlignmentFit, acAlignmentAligned
            alignmentPoint(0) = objText.insertionPoint(0): alignmentPoint(1) = objText.insertionPoint(1): alignmentPoint(2) = CDbl(objText.TextString)
            objText.insertionPoint = alignmentPoint
          Case Else
            alignmentPoint(0) = objText.TextAlignmentPoint(0): alignmentPoint(1) = objText.TextAlignmentPoint(1): alignmentPoint(2) = CDbl(objText.TextString)
            objText.TextAlignmentPoint = alignmentPoint
        End Select
        intCnt = intCnt + 1
      Else
        intSkipped = intSkipped + 1
      End If
    Next
    
  ss.Delete
  
  MsgBox intCnt & " Object(s) edited." & vbCrLf & _
  intSkipped & " Object(s) skipped."
  
  
  Exit Sub
  
errHandler:
  MsgBox "An error has occurred: " & Err.Description

End Sub

Good Luck,

Scott
 
Thanks for the quick response, i have tried vbaide in both AutoCAD 2000 & AutoCADlt 2000 & they both say Unknown command?

Any suggestions?

Cheers
 
editZ will not be an Autocad command. Once you have pasted the code in the IDE, go back to acad and type vbarun. There should be one macro listed for you to run - that being editZ.

Scott
 
Sorry - upon further review I mis-understood your previous post. VBAIDE will not be available in LT - but it should be available in AutoCAD. If memeory serves in 2000, you may need to pop the install cd in and select "Custom" and add VBA capabilities.

Scott
 
You are correct, the VB capabilities are loaded/not loaded at install. Keep in mind, AutoCAD 2000 has a different version of VB running than later AutoCAD versions (coding may possibly need to be tweaked). Good luck.
 
Thanks LochDhu thats exactly what i was after.
FAM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top