Dynamic blocks editing..

Dynamic blocks editing..

Anonymous
Not applicable
748 Views
9 Replies
Message 1 of 10

Dynamic blocks editing..

Anonymous
Not applicable
Hi all,
I have two things to get cleared...

1. Can i stretch the dynamic block to the predefined length values programmatically using VBA?
2. what objects of AutoCAD are exposed to class modules?
for example: I want to define a class object that contains the a selection set of objects and should have the methods like move, rotate.. etc.. can i do it in VBA?
thanks in advance...
hope i am too one among those are getting a great help here..
Asty
0 Likes
749 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
To answer the 2nd question first as far as I know all Autocad Entities are exposed.

I have been programming dynamic blocks for about 6 months now.
Since the predefined lengths would be a dynamic property you would use the
GetDynamicBlockProperties property of a block reference to get and/or change the lenght.
I work primarily with the visibility states but the attached form may have some routines
that help.
[note use these at your own risk, YADA,YADA,YADA, etc.]
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com

On Tue, 16 Jan 2007 16:48:07 +0000, satyareddy <> wrote:

>Hi all,
>I have two things to get cleared...
>
>1. Can i stretch the dynamic block to the predefined length values programmatically using VBA?
>2. what objects of AutoCAD are exposed to class modules?
> for example: I want to define a class object that contains the a selection set of objects and should have the methods like move, rotate.. etc.. can i do it in VBA?
>thanks in advance...
>hope i am too one among those are getting a great help here..
>Asty
0 Likes
Message 3 of 10

Anonymous
Not applicable
I will try to help.
To answer your second question, as far as I am aware you can expose any autocad entity
that has an automation interface.

As to the 1st issue. I have been modifying dynamic blocks for about 6 months now
(primarily using the visibility state) with VBA. The following code should help to get
you started:

sample to get all available visibility states:
[code]
Public Function CSI_GetVisList(Blk As IAcadBlockReference) As Variant
Dim PropList As Variant
Dim Prop As AcadDynamicBlockReferenceProperty
Dim i As Long
CSI_GetVisList = Empty ' preset function
If Blk.IsDynamicBlock Then ' only want to work with Dynamic Blocks
PropList = Blk.GetDynamicBlockProperties ' Get all of the dynamic properites
For i = LBound(PropList) To UBound(PropList) ' Cycle through all dynamic properties
Set Prop = PropList(i)
If Prop.PropertyName = "Visibility" Then ' if this is the visibilty property
CSI_GetVisList = Prop.AllowedValues ' return all allowed values
Exit For
End If
Next i
End If
End Function
[\code]
Sample to get the current visibility state:
[code]
Public Function CSI_GetCurVis(Blk As IAcadBlockReference) As Variant
Dim PropList As Variant
Dim Prop As AcadDynamicBlockReferenceProperty
Dim i As Long
CSI_GetCurVis = Empty ' preset function
If Blk.IsDynamicBlock Then ' only work with Dynamic Blocks
PropList = Blk.GetDynamicBlockProperties ' Get all dynamic properties
For i = LBound(PropList) To UBound(PropList) ' Cycle through all properties
Set Prop = PropList(i)
If Prop.PropertyName = "Visibility" Then ' if this is the visibility property
CSI_GetCurVis = Prop.Value ' get the current visibility state
Exit For
End If
Next i
End If
End Function
[\code]
Sample to set the visibility state:
[code]
Public Sub CSI_SetCurVis(VisState As String, Block As IAcadBlockReference)
Dim PropList As Variant
Dim Prop As AcadDynamicBlockReferenceProperty
Dim i As Long
If Block.IsDynamicBlock Then ' only work with Dynamic Blocks
PropList = Block.GetDynamicBlockProperties ' Get all dynamic properties
For i = LBound(PropList) To UBound(PropList) ' Cycle through all properties
Set Prop = PropList(i)
If Prop.PropertyName = "Visibility" Then ' if this is the visibility property
Prop.Value = VisState ' Set visibility (note will not return error if
non-existing choice)
Exit Sub
End If
Next i
End If
End Sub
[\code]

Hope these help you!
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com

On Tue, 16 Jan 2007 16:48:07 +0000, satyareddy <> wrote:

>Hi all,
>I have two things to get cleared...
>
>1. Can i stretch the dynamic block to the predefined length values programmatically using VBA?
>2. what objects of AutoCAD are exposed to class modules?
> for example: I want to define a class object that contains the a selection set of objects and should have the methods like move, rotate.. etc.. can i do it in VBA?
>thanks in advance...
>hope i am too one among those are getting a great help here..
>Asty
0 Likes
Message 4 of 10

Anonymous
Not applicable
Thanks Mr. Phil Custer
Elaborating on the second question..
I have learnt that vba cannot support custom object creation through the classes.
For suppose can i define the object definition in a class as call an instance of it like any other ACAD object(ex;- acadlwpolyline,etc...).

If i cannot do it in VBA, can I atleast create a class object that is a collection of entities and will have the methods like move, rotate it etc...
thanks
regards
Asty
0 Likes
Message 5 of 10

Anonymous
Not applicable
Please help me with this i am i little urgency..
0 Likes
Message 6 of 10

Anonymous
Not applicable
I am sorry I am not sure I understand what it is you are trying to do.
Could you post some psuedo code of what you would like the end result to look like?

Also appologies for response time but like several of the responders to this group I have
real job that requires travel and time away from monitoring news groups.
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com
On Wed, 17 Jan 2007 18:26:59 +0000, satyareddy <> wrote:

>Please help me with this i am i little urgency..
0 Likes
Message 7 of 10

Anonymous
Not applicable
thanks ..

i am putting a pseudo code here...

create a class named "clscar"

copy the objects on a layer to the selection ssetcar.
define the properties-set all the objects in the ssetcar to the property clscar.objs
define methods like clscar.move , clscar .rotate.etc..

now i defined a class..
i now want to create an instance of the class car like
dim objcar as new clscar.

and access its properties and methods..
like car.move..
i hope atleast this time i am making some sense


thanks in advance..
Asty
0 Likes
Message 8 of 10

Anonymous
Not applicable
I will try to give some general guidance on what might help.
Just so that you know this appears to be a fairly aggressive project.

You would most likely want to use code something like the following:
[code] in class module
Option Explicit

Private p_SSet As AcadSelectionSet
Private p_HasEntities As Boolean
Private p_Layer As AcadLayer
Private p_Dwg As AcadDocument

Private Sub Class_Initialize()
p_HasEntities = False
If Application.Documents.Count = 0 Then ' There are no open documents return an error
Err.Raise Number:=vbObjectError + 1, Source:="clsSet.Initialize", _
Description:="No Open Document"
Exit Sub
End If
p_Dwg = ThisDrawing
End Sub

Private Sub Class_Terminate()
p_SSet.Clear ' empty the set
p_SSet.Delete ' delete the set
End Sub

Public Property Get Layer() As AcadLayer
If p_HasEntities Then ' class has been loaded
Set Layer = p_Layer
Else
Set Layer = Null
End If
End Property

Public Property Set Layer(ByVal l_Layer As AcadLayer)
Set p_Layer = l_Layer ' set layer
LoadSet
End Property

Private Sub LoadSet()
Dim l_SSet As AcadSelectionSet
Dim SSFound As Boolean
Dim SSetName As String
Dim SSFilterType(0) As Integer
Dim SSFilterData(0) As Variant
If Not p_HasEntities Then Exit Sub
If ThisDrawing.SelectionSets.Count >= 128 Then ' There are more than 128 selection sets
return error
Err.Raise Number:=vbObjectError + 3, Source:="clsSet.LoadSet", _
Description:="Can not Create Selection Set 128 Already Exist"
End If
SSetName = "clsSet" ' Should be unique in your drawing
SSFound = False ' Start with no Selection Set Found
For Each l_SSet In p_Dwg.SelectionSets ' Parse Collection
If l_SSet.Name = SSetName Then ' Found a hit
SSFound = True ' Tell the rest of the program about it
Exit For ' Stop Parsing we found what we want
End If
Next l_SSet
If Not SSFound Then ' There is no selection set we want
Set l_SSet = ThisDrawing.SelectionSets.Add(SSetName) ' So Make it
End If
Set p_SSet = l_SSet ' Set to class varialbe
p_SSet.Clear ' Empty set first
SSFilterType(0) = 8 ' Filter on Entity Layer
SSFilterData(0) = p_Layer.Name ' Layer name to select
p_SSet.Select acSelectionSetAll, , , SSFilterType, SSFilterData ' Fill set with all
entities on layer
p_HasEntities = True ' tell the rest of the class we have enties
End Sub

Public Sub Move()
If Not p_HasEntities Then Exit Sub ' can work with an empty set
' Code to work with the entiteis in p_sset goes here
'
End Sub
[\code]

You can use this as a start.
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com

On Thu, 18 Jan 2007 04:52:20 +0000, satyareddy <> wrote:

>thanks ..
>
>i am putting a pseudo code here...
>
>create a class named "clscar"
>
>copy the objects on a layer to the selection ssetcar.
>define the properties-set all the objects in the ssetcar to the property clscar.objs
>define methods like clscar.move , clscar .rotate.etc..
>
>now i defined a class..
>i now want to create an instance of the class car like
>dim objcar as new clscar.
>
>and access its properties and methods..
>like car.move..
>i hope atleast this time i am making some sense
>
>
>thanks in advance..
>Asty
0 Likes
Message 9 of 10

Anonymous
Not applicable
To answer the 2nd question first as far as I know all Autocad Entities are exposed.

I have been programming dynamic blocks for about 6 months now.
Since the predefined lengths would be a dynamic property you would use the
GetDynamicBlockProperties property of a block reference to get and/or change the lenght.
I work primarily with the visibility states but the attached form may have some routines
that help.
[note use these at your own risk, YADA,YADA,YADA, etc.]
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com

On Tue, 16 Jan 2007 16:48:07 +0000, satyareddy <> wrote:

>Hi all,
>I have two things to get cleared...
>
>1. Can i stretch the dynamic block to the predefined length values programmatically using VBA?
>2. what objects of AutoCAD are exposed to class modules?
> for example: I want to define a class object that contains the a selection set of objects and should have the methods like move, rotate.. etc.. can i do it in VBA?
>thanks in advance...
>hope i am too one among those are getting a great help here..
>Asty
0 Likes
Message 10 of 10

Anonymous
Not applicable
Thanks.. phil..thats great..thats what i was exactly looking for
..
thanks for your consideration
0 Likes