AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to deal with this...

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
246 Views, 4 Replies

how to deal with this...

okay Peter "VBA" Funk help me out..
I am working on this and in LISP and VBA I get the same result
I opened a AEC Template Intl or Imperial Template.
it returns "" how do I get the Listing of layers associated with
that????
thanks ....


Sub NM_qlyrstd()
' Set ADT Drawing Scale
Dim aecDb As New AecArchBaseDatabase ' declare and assign an aecArch
Database
' Dim aecPref As ThisDrawing.AecBaseDatabasePreferences ' declare the
arch preferences object
Dim Scl As String ' declare a double (floating point) variable
aecDb.Init ThisDrawing.Database ' initialise our arch database
fromtheActive drawing
Set dbPref = aecDb.Preferences ' assign the preferences object(objects
are assigned using the syntax "Set var = otherObj"
Dim laystandard As String
laystandard = dbPref.LayerStandard
On Error Resume Next

MsgBox "The current value for LayerStandard is: " & laystandard, _
vbInformation, "LayerStandard Example"
End Sub
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Nauman,

I'm thinking that you are getting that "default" because the layer standard
isn't set? Here is the code from the help file that will list all the layers
to the "Immediate" window inside of the IDE. (FYI you should always have
that turn on, as well as "Locals") Also, under "Tools" -> "Options" I feel
that the default checks are in the wrong place for the "Editor" I have mine
set to NO Auto Syntax Check (avoids the annoying dialog box) and YES to
"Require Variable Declaration". This places "Option Explicit" at the top of
all your code, and forces you to "Dim" your variables before you use them.
Not only is this good programming, but it also allows VBA to provide you
with Intellisense as your go.

Cheers,

Peter Funk
API Product Manager
Building Industry Division
Autodesk, Inc.


Public Sub Dump_Keys
Dim doc As AecArchBaseDocument
Dim dbPref As AecArchBaseDatabasePreferences
Dim cLayerKeyStyles As AecLayerKeyStyles
Dim layerKeyStyle As AecLayerKeyStyle
Dim cLayerKeys As AecLayerKeys
Dim layerKey As AecLayerKey

Set doc = AecArchBaseApplication.ActiveDocument
Set cLayerKeyStyles = doc.LayerKeyStyles
Set dbPref = doc.Preferences
' Sets the layer key style to the current layer standard
Set layerKeyStyle = cLayerKeyStyles.Item(dbPref.LayerStandard)
Set cLayerKeys = layerKeyStyle.Keys

For Each layerKey In cLayerKeys
Debug.Print layerKey.Name
Debug.Print " Color - " & layerKey.Color
Debug.Print " Layer - " & layerKey.Layer
Debug.Print " LineType - " & layerKey.Linetype
Debug.Print " Lineweight - " & layerKey.Lineweight
Debug.Print " Plotstyle - " & layerKey.PlotStyleName
Debug.Print " Plottable - " & layerKey.Plottable
Debug.Print " Removable - " & layerKey.Removeable
Next
End Sub
Message 3 of 5
Anonymous
in reply to: Anonymous

Excuse my ignorance here in VBA but his code aint working in ADT3 at home
I have both aEc object 3.0 libraries checked
it says Object required runtime error 424 at..
Set doc = AecArchBaseApplication.ActiveDocument



, I am in ADT3 right now (at home)
and what is the difference between this
Dim aecDb As New AecArchBaseDatabase
' Dim doc As AecArchBaseDocument


Set dbPref = doc.Preferences
Set dbPref = aecDb.Preferences

cause if I do it the other way , i.e. aecDb way it says IAecLayerKeyStyles
failed.

I think I first need to really understand the Dim As New xxxx
dim doc as etc..
as I right now have not clue what they mean and why etc...

btw my solution is posted below (in Lisp of course)


Public Sub Dump_Keys()
Dim aecDb As New AecArchBaseDatabase
' Dim doc As AecArchBaseDocument
aecDb.Init ThisDrawing.Database
Dim dbPref As AecArchBaseDatabasePreferences
Dim cLayerKeyStyles As AecLayerKeyStyles
Dim layerKeyStyle As AecLayerKeyStyle
Dim cLayerKeys As AecLayerKeys
Dim layerKey As AecLayerKey

Set doc = AecArchBaseApplication.ActiveDocument
Set cLayerKeyStyles = doc.LayerKeyStyles
Set dbPref = aecDb.Preferences



(setq currentstyle (getaecvar 9))
(if (eq (getaecvar 9) "");; if the lyrstd is Default then find
the info in the reg...
(progn
(if (or
;;imperial
(eq (getaecvar 71) 30) ;Feet
(eq (getaecvar 71) 31) ;Inches
)
(setq currentstyle (vl-registry-read
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Autodesk\\ObjectDBX\\R15.0\\AEC\\3.0\\AecBase
\\Defaults\\DwgSetup\\Imperial" "LayerStandard"))
)
);progn
;otherwise it is a metric drawing
(setq currentstyle (vl-registry-read
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Autodesk\\ObjectDBX\\R15.0\\AEC\\3.0\\AecBase
\\Defaults\\DwgSetup\\Metric" "LayerStandard"))
)
"Peter Funk - Autodesk, Inc" wrote in message
news:76DE55CDAE9F99C9076528C4A1B37A4D@in.WebX.maYIadrTaRb...
> Nauman,
>
> I'm thinking that you are getting that "default" because the layer
standard
> isn't set? Here is the code from the help file that will list all the
layers
> to the "Immediate" window inside of the IDE. (FYI you should always have
> that turn on, as well as "Locals") Also, under "Tools" -> "Options" I feel
> that the default checks are in the wrong place for the "Editor" I have
mine
> set to NO Auto Syntax Check (avoids the annoying dialog box) and YES to
> "Require Variable Declaration". This places "Option Explicit" at the top
of
> all your code, and forces you to "Dim" your variables before you use them.
> Not only is this good programming, but it also allows VBA to provide you
> with Intellisense as your go.
>
> Cheers,
>
> Peter Funk
> API Product Manager
> Building Industry Division
> Autodesk, Inc.
>
>
> Public Sub Dump_Keys
> Dim doc As AecArchBaseDocument
> Dim dbPref As AecArchBaseDatabasePreferences
> Dim cLayerKeyStyles As AecLayerKeyStyles
> Dim layerKeyStyle As AecLayerKeyStyle
> Dim cLayerKeys As AecLayerKeys
> Dim layerKey As AecLayerKey
>
> Set doc = AecArchBaseApplication.ActiveDocument
> Set cLayerKeyStyles = doc.LayerKeyStyles
> Set dbPref = doc.Preferences
> ' Sets the layer key style to the current layer standard
> Set layerKeyStyle = cLayerKeyStyles.Item(dbPref.LayerStandard)
> Set cLayerKeys = layerKeyStyle.Keys
>
> For Each layerKey In cLayerKeys
> Debug.Print layerKey.Name
> Debug.Print " Color - " & layerKey.Color
> Debug.Print " Layer - " & layerKey.Layer
> Debug.Print " LineType - " & layerKey.Linetype
> Debug.Print " Lineweight - " & layerKey.Lineweight
> Debug.Print " Plotstyle - " & layerKey.PlotStyleName
> Debug.Print " Plottable - " & layerKey.Plottable
> Debug.Print " Removable - " & layerKey.Removeable
> Next
> End Sub
>
>
Message 4 of 5
jbuzbee
in reply to: Anonymous

Nauman - No! Bad! resist the temptation of the dark side. Yes that is the quicker way, but, we have been shown the light. Use the Force Nauman, use the Force . . .. Jim "the VBA jedi" Buzbee.
Message 5 of 5
Anonymous
in reply to: Anonymous

Nauman,

1. You should have 4 AEC things checked; two application, and two object
libraries. Without all 4, you will get errors.

2. The "Document" is an AutoCAD drawing, a "Database" is also a AutoCAD
drawing, but could also be a XRef.

3. In ADT 2.0, you had to do "Init" on the database object, this has been
changed to a cleaner version with 3+. See my example code.

4. If you get "" back for then ADT is set to draw everything on the
current layer. Reading the reg may not help either, as the key may be blank.
I think that you got that runtime error when you tried to get the layer key
style with "".

5. Here is the code again with a trap for the standard:

Public Sub Dump_Keys()
Dim doc As AecArchBaseDocument
Dim dbPref As AecArchBaseDatabasePreferences
Dim cLayerKeyStyles As AecLayerKeyStyles
Dim layerKeyStyle As AecLayerKeyStyle
Dim cLayerKeys As AecLayerKeys
Dim layerKey As AecLayerKey

Set doc = AecArchBaseApplication.ActiveDocument
Set cLayerKeyStyles = doc.LayerKeyStyles
Set dbPref = doc.Preferences
' Sets the layer key style to the current layer standard
If dbPref.LayerStandard <> "" Then
Set layerKeyStyle = cLayerKeyStyles.Item(dbPref.LayerStandard)
Set cLayerKeys = layerKeyStyle.Keys

For Each layerKey In cLayerKeys
Debug.Print layerKey.Name
Debug.Print " Color - " & layerKey.Color
Debug.Print " Layer - " & layerKey.Layer
Debug.Print " LineType - " & layerKey.Linetype
Debug.Print " Lineweight - " & layerKey.Lineweight
Debug.Print " Plotstyle - " & layerKey.PlotStyleName
Debug.Print " Plottable - " & layerKey.Plottable
Debug.Print " Removable - " & layerKey.Removeable
Next
Else
Debug.Print "Layer Standard is "
End If
End Sub

Peter Funk
API Product Manager
Building Industry Division
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report

”Boost