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

Reading part of dwg props

1 REPLY 1
Reply
Message 1 of 2
Anonymous
235 Views, 1 Reply

Reading part of dwg props

Hi,
Im just starting out with xrecords and am trying to access the custom
drawing properties.
For testing, I set the 'first' custom property in acad as

name: jobNo value: 0111

Im trying to get the value 0111 from the drawing props by using the script
below.
But it returns JobNo=0111 instead just 0111. Can anyone shine some light on
what im mincing my head over.

Cheers
Keith

ive commented through the script to illustrate what im thinking
Heres the script so far :

Sub initDetails()

'Declare dwgprop variables
Dim diction As AcadDictionary
Dim objDwgInfo As AcadXRecord
Dim varDataType As Variant
Dim varData As Variant
Dim intI As Integer
Dim unset As String 'For properties not set

'Set text for displaying unset dwgprops
unset = "Please Enter"

'Set dictionary name to use the dwgprops xrecord
Const DICTIONARY_NAME = "DWGPROPS"
On Error GoTo HandleError

'Set objDwgInfo to get dwgprops data
Set objDwgInfo = ThisDrawing.Dictionaries(DICTIONARY_NAME)
objDwgInfo.GetXRecordData varDataType, varData

'loop through each property to identify records and use data as required
For intI = LBound(varDataType) To UBound(varDataType)
'Uncomment the next line to use propmt utility for debugging
'ThisDrawing.Utility.Prompt vbCrLf & varDataType(intI) & vbTab &
varData(intI)

'Test each property
'JobNo
If varDataType(intI) = 300 Then
If varData(intI) = "" Then
JobNoTxt.Value = unset
Else
JobNoTxt.Value = varData(intI)
End If
End If

'dwg number
'as above... etc etc

Next intI

ExitHere:
Exit Sub

HandleError:
MsgBox "Drawing Properties have not been set"
Resume ExitHere

End Sub
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

keith had this to say
:
> But it returns JobNo=0111 instead just 0111.

That is correct; the property is stored just as you see even though it
is not displayed that way in the properties dialog. Just use Mid to
retrieve everything to the left of the equal sign:

' Assumes sJob is "JobNo=0111"
Mid(sJob, Instr(sJob, "="))

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report