Attributes in UserForm

Attributes in UserForm

Anonymous
Not applicable
733 Views
10 Replies
Message 1 of 11

Attributes in UserForm

Anonymous
Not applicable
Hi.

I've got a Problem to solve this:

In my drawing is a very huge Block with Attributes. Definitly too much to change them with -attedit.

So i wanna build a userform and put all of them inside, to modify them and write back into this block.

They are buildet like this (table):
attA01 attB01 attC01 attD01
attA02 attB02 attC02 attD02 ......

Any suggestions how i can build this form dynamically and setting the source onto the right place of the block to write them back...without using more than 400 times case 🙂

Thanks for helping me
ML
0 Likes
734 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
I would suggest creating a form as follows:
1. create form with 5 lables with 5 text boxes
2. Add "Pick Block", "Quit", "Next Group", and "Last Group" buttons to the form
3. In the forms declarations section add:
[code]
Private p_BlkRef As IAcadBlockReference2 ' The block being edited
Private p_BlockLoaded as Boolean ' True if there is a block loaded
Private p_AttribCount as Long ' A count of where we are in the attribute reference list
Private p_AttribMax as Long ' How many attribs there are in the block
Private p_Attribs as Variant ' The list of all Attributes
Private p_ModAttrib1 As IAcadAttributeReference2 ' The 1st attribute
Private p_ModAttrib2 As IAcadAttributeReference2
Private p_ModAttrib3 As IAcadAttributeReference2
Private p_ModAttrib4 As IAcadAttributeReference2
Private p_ModAttrib5 As IAcadAttributeReference2
[/code]
4. In the form's initialize event set p_BlockLoaded to False and the set the enable of the
labels, text boxes and the next and last buttons to False.
5. In the pick block button's click code you can then set the labels, text boxes and
buttons to enabled; Add the follwing code to load the attribs
[code]
...
if p_BlkRef.HasAttributes then
p_Attribs = p_BlkRef.GetAttributes
p_AttribMax = Ubound(p_Attribs)
p_AttribCount = 0 ' The first Attribute is subscript 0
LoadAttribData ' This is a subroutine that loads the data
else
' code to deal with no attributes
endif
...
Private Sub LoadAttribData()
Set p_ModAttrib1 = p_Attribs(p_AttribCount)
Label1.Tag = p_ModAttrib1.TagString
TextBox1.Text = p_ModAttrib1.TextString
p_AttribCount = p_AttribCount + 1
If p_AttribCount > p_AttribMax Then
p_AtEnd = True
p_AttribCount = p_AttribMax
bntNext.Enabled = False
Else
Set p_ModAttrib2 = p_Attribs(p_AttribCount)
Label2.Tag = p_ModAttrib2.TagString
TextBox2.Text = p_ModAttrib2.TextString
p_AttribCount = p_AttribCount + 1
If p_AttribCount > p_AttribMax Then
p_AtEnd = True
p_AttribCount = p_AttribMax
bntNext.Enabled = False
Else
...
' fill out the rest here
...
End If
End If
End Sub
[/code]

6. In each text box change event write the textbox?.text back to the
p_ModAttrib?.TextString.
7. The "Next Group" and "Last Group" button code should incrament or decrament the
p_AttribCount by 5 and then call the LoadAttribData sub, remember to check agains the max
count and 0

I hope this can get you started!
Phil Custer, P.E.
Custer Services, Inc.
custer@landfillgas.com

On Wed, 30 Aug 2006 16:46:30 +0000, Lappi <> wrote:

>Hi.
>
>I've got a Problem to solve this:
>
>In my drawing is a very huge Block with Attributes. Definitly too much to change them with -attedit.
>
>So i wanna build a userform and put all of them inside, to modify them and write back into this block.
>
>They are buildet like this (table):
>attA01 attB01 attC01 attD01
>attA02 attB02 attC02 attD02 ......
>
>Any suggestions how i can build this form dynamically and setting the source onto the right place of the block to write them back...without using more than 400 times case 🙂
>
>Thanks for helping me
>ML
0 Likes
Message 3 of 11

Anonymous
Not applicable
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 4 of 11

Anonymous
Not applicable
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 5 of 11

Anonymous
Not applicable
You might also want to consider using an OCW spreadsheet control. I've used
it many times and it works great. As long as Excel is installed on each
machine
you have a liscense to use. OWC stands for Office Web Components, but don't
let the web part fool you.

Right-click on your tool box and browse add Microsoft Spreadsheet. Works
very similar to excel. There is alos a vba help menu for the controls in
your office
directroy. OWCVBA11.vba or such.

"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 6 of 11

Anonymous
Not applicable
Hi John,

If you have Civil 3D installed, their is a Flexgrid control in the
Alignment/Station report program. If you work with that, you know it will
be installed for Civil 3D users. It's a bit quirky, but can be used once
you get the hang of it.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 7 of 11

Anonymous
Not applicable
Laurie, Paul,

Thank you for the info I'll check the Civil 3D sample you noted as I am
using C3D.
From Paul's post it sounds like I might be able to use the same cell calls I
have in older excel routines.
is that correct? I have tons of routines that post data to excel, if I could
reuse them that would be sweet instead of having to create new ones.
Any links you know of working with the OWC where the user enters column data
like station & offset in the form based excel component and then
run to place in the drawing. I done a lot of these in the past but I've used
comma delimited text files to read in the data for Land functions. I would
be great to have that data available for the person to edit in the form if
they didn't like the results.

Thanks and have a great day
John Coon

"Laurie Comerford" wrote in message
news:5318852@discussion.autodesk.com...
Hi John,

If you have Civil 3D installed, their is a Flexgrid control in the
Alignment/Station report program. If you work with that, you know it will
be installed for Civil 3D users. It's a bit quirky, but can be used once
you get the hang of it.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 8 of 11

Anonymous
Not applicable



Yes you can. You will have calls like Spreadsheet1.ActiveSheet.Cells...
so just prefacing your Excel Cell calls with the Spreadsheet... will get you
close.

>Any links you know of working with the OWC where the user enters column
>data
>like station & offset in the form based excel component and then
>run to place in the drawing.

May samples of using the control on the web. Very simple to use with
AutoCad since you are already there. Simple calls, using 'ThisDrawing'
and 'Spreadsheet1' directly to communicate between the two. It also
imports and exports csv files directly which is nice, and offers modest
events. The help file if pretty good, just have at it and you'll pick it up
quick. I was just winging it a few years back, before I even knew there
was a help file for it, and found it intuitive.

Post if you have any problems.

"john coon" wrote in message
news:5318934@discussion.autodesk.com...
Laurie, Paul,

Thank you for the info I'll check the Civil 3D sample you noted as I am
using C3D.
From Paul's post it sounds like I might be able to use the same cell calls I
have in older excel routines.
is that correct? I have tons of routines that post data to excel, if I could
reuse them that would be sweet instead of having to create new ones.
Any links you know of working with the OWC where the user enters column data
like station & offset in the form based excel component and then
run to place in the drawing. I done a lot of these in the past but I've used
comma delimited text files to read in the data for Land functions. I would
be great to have that data available for the person to edit in the form if
they didn't like the results.

Thanks and have a great day
John Coon

"Laurie Comerford" wrote in message
news:5318852@discussion.autodesk.com...
Hi John,

If you have Civil 3D installed, their is a Flexgrid control in the
Alignment/Station report program. If you work with that, you know it will
be installed for Civil 3D users. It's a bit quirky, but can be used once
you get the hang of it.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 9 of 11

Anonymous
Not applicable
Paul,

Thanks, I will give it a try. Most of the simple routines I do include
writing in or writing out data to text or excel files.
I would be nice to be able to see or edit those excel files before I run
them. It should be a fun learning experience. Thank you for your time.

Have a great day
John Coon

"Paul Richardson" wrote in message
news:5318943@discussion.autodesk.com...



Yes you can. You will have calls like Spreadsheet1.ActiveSheet.Cells...
so just prefacing your Excel Cell calls with the Spreadsheet... will get you
close.

>Any links you know of working with the OWC where the user enters column
>data
>like station & offset in the form based excel component and then
>run to place in the drawing.

May samples of using the control on the web. Very simple to use with
AutoCad since you are already there. Simple calls, using 'ThisDrawing'
and 'Spreadsheet1' directly to communicate between the two. It also
imports and exports csv files directly which is nice, and offers modest
events. The help file if pretty good, just have at it and you'll pick it up
quick. I was just winging it a few years back, before I even knew there
was a help file for it, and found it intuitive.

Post if you have any problems.

"john coon" wrote in message
news:5318934@discussion.autodesk.com...
Laurie, Paul,

Thank you for the info I'll check the Civil 3D sample you noted as I am
using C3D.
From Paul's post it sounds like I might be able to use the same cell calls I
have in older excel routines.
is that correct? I have tons of routines that post data to excel, if I could
reuse them that would be sweet instead of having to create new ones.
Any links you know of working with the OWC where the user enters column data
like station & offset in the form based excel component and then
run to place in the drawing. I done a lot of these in the past but I've used
comma delimited text files to read in the data for Land functions. I would
be great to have that data available for the person to edit in the form if
they didn't like the results.

Thanks and have a great day
John Coon

"Laurie Comerford" wrote in message
news:5318852@discussion.autodesk.com...
Hi John,

If you have Civil 3D installed, their is a Flexgrid control in the
Alignment/Station report program. If you work with that, you know it will
be installed for Civil 3D users. It's a bit quirky, but can be used once
you get the hang of it.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 10 of 11

Anonymous
Not applicable
You're welcome. Nice thing is, users have excel built right
into AutoCAD. Don't unload your form containing the
spreadsheet when it's closed and the data will persist until
the drawing is closed. You can also caputre the closing of
the drawing and do some testing to see if you need to
prompt them for a save. Obviously you can have a save
button right on the form also, but they will forget to use
it.

Check the properties for the spreadsheet once you dump
it on a form. Lots there to customize. Also, the control is
version sensitive so make sure you use the same version
of the control the users will be using. The latest version
will be availible when you right-click on the toolbox,
but you can browse to older versions for every version
of Excel you have installed.

gl-Paul

"john coon" wrote in message
news:5320416@discussion.autodesk.com...
Paul,

Thanks, I will give it a try. Most of the simple routines I do include
writing in or writing out data to text or excel files.
I would be nice to be able to see or edit those excel files before I run
them. It should be a fun learning experience. Thank you for your time.

Have a great day
John Coon

"Paul Richardson" wrote in message
news:5318943@discussion.autodesk.com...



Yes you can. You will have calls like Spreadsheet1.ActiveSheet.Cells...
so just prefacing your Excel Cell calls with the Spreadsheet... will get you
close.

>Any links you know of working with the OWC where the user enters column
>data
>like station & offset in the form based excel component and then
>run to place in the drawing.

May samples of using the control on the web. Very simple to use with
AutoCad since you are already there. Simple calls, using 'ThisDrawing'
and 'Spreadsheet1' directly to communicate between the two. It also
imports and exports csv files directly which is nice, and offers modest
events. The help file if pretty good, just have at it and you'll pick it up
quick. I was just winging it a few years back, before I even knew there
was a help file for it, and found it intuitive.

Post if you have any problems.

"john coon" wrote in message
news:5318934@discussion.autodesk.com...
Laurie, Paul,

Thank you for the info I'll check the Civil 3D sample you noted as I am
using C3D.
From Paul's post it sounds like I might be able to use the same cell calls I
have in older excel routines.
is that correct? I have tons of routines that post data to excel, if I could
reuse them that would be sweet instead of having to create new ones.
Any links you know of working with the OWC where the user enters column data
like station & offset in the form based excel component and then
run to place in the drawing. I done a lot of these in the past but I've used
comma delimited text files to read in the data for Land functions. I would
be great to have that data available for the person to edit in the form if
they didn't like the results.

Thanks and have a great day
John Coon

"Laurie Comerford" wrote in message
news:5318852@discussion.autodesk.com...
Hi John,

If you have Civil 3D installed, their is a Flexgrid control in the
Alignment/Station report program. If you work with that, you know it will
be installed for Civil 3D users. It's a bit quirky, but can be used once
you get the hang of it.

--

Laurie Comerford
CADApps
www.cadapps.com.au
"john coon" wrote in message
news:5318566@discussion.autodesk.com...
Fatty,

How do you connect to a flexgrid?

John Coon
wrote in message news:5314101@discussion.autodesk.com...
You can play with FlexGrid or SpreadSheet controls
See example with SpreadSheet control

~'J'~
0 Likes
Message 11 of 11

Anonymous
Not applicable
Hi.
Thank you for the answers.

I think i'll try both ways...TextBox and FlexGrid .

My Version with TextBox is almost done...but there seemed to be a big problem with the focus in multipages (form)...it dosen't seemed to be possible to set the fokus to active.control, because my active.control is almost page1.

FlexGrid seemed to be ... more flexible 😉

Excel ... jepp this way should be the best. But i wanna try another way to solve this problem.

Best regards and thanks
Lappi
0 Likes