View Full Version : need a dynamic block guru...
james.126519
2007-11-13, 05:43 PM
I am not going to explain what I need this for because it would take too much of everyones time. So, I am going to just dumb it down to the basics. I really hope someone will be able to help, it will make my work much nicer :)
i want to create 3 blocks that are nothing more than rectangles 2"x6". I'll call one block "A", and the other two "B" and "C". the dynamic properties of the blocks are simple, just a stretch mode that i can adjust the 6" dimension to whatever length i want. I dont want to change the 2" dimension. Inside each rectangle, I want an attribute that at some point i can label the block with a part mark.
Once i have all of my blocks stretched to the lengths i need, i would like to use EATTEXT to extract the block name, attribute value and the distances into a table. Keep in mind that i have not filled out any of the attributes in the blocks.
Up to this point its simple and im good to go.
But, once i have the table created, does anyone know of a way that i can fill in the blanks in the table under the attribute column, and have that information transfer to all of the blocks that line is referencing? I have an example attached..
Chris.N
2007-11-13, 06:06 PM
I am not going to explain what I need this for because it would take too much of everyones time. So, I am going to just dumb it down to the basics. I really hope someone will be able to help, it will make my work much nicer :)
i want to create 3 blocks that are nothing more than rectangles 2"x6". I'll call one block "A", and the other two "B" and "C". the dynamic properties of the blocks are simple, just a stretch mode that i can adjust the 6" dimension to whatever length i want. I dont want to change the 2" dimension. Inside each rectangle, I want an attribute that at some point i can label the block with a part mark.
Once i have all of my blocks stretched to the lengths i need, i would like to use EATTEXT to extract the block name, attribute value and the distances into a table. Keep in mind that i have not filled out any of the attributes in the blocks.
Up to this point its simple and im good to go.
But, once i have the table created, does anyone know of a way that i can fill in the blanks in the table under the attribute column, and have that information transfer to all of the blocks that line is referencing? I have an example attached..
not without programming or some add-on package (that i'm unaware of)
why not have whatever info you need filled in via fields in attributes? they can at least get you half-way there if you're just trying to match extrusion profiles.
um, let me explain further. you have vis states (or whatever) labeled as "A", "B", etc., so just have a field in an attribute match that state, and just add on after the field your additional tag data.
james.126519
2007-11-13, 06:38 PM
not without programming or some add-on package (that i'm unaware of)
why not have whatever info you need filled in via fields in attributes? they can at least get you half-way there if you're just trying to match extrusion profiles.
um, let me explain further. you have vis states (or whatever) labeled as "A", "B", etc., so just have a field in an attribute match that state, and just add on after the field your additional tag data.
well, what I am trying to accomplish is an automatic cut list. If i can use dynamic blocks to stick build a curtainwall elevation, then just extract the properties into a table it cuts my time in half. but, i then need to put partmarks on my elevations so that my shop and field personnel know where each part goes for fabrication and installation. so, the last part i was looking for was to automatically part mark the elevations.
Capt. Computer Crasher
2007-11-13, 07:51 PM
well, what I am trying to accomplish is an automatic cut list. If i can use dynamic blocks to stick build a curtainwall elevation, then just extract the properties into a table it cuts my time in half. but, i then need to put partmarks on my elevations so that my shop and field personnel know where each part goes for fabrication and installation. so, the last part i was looking for was to automatically part mark the elevations.
Which AutoCAD are you using?
In AutoCAD 2008 you can extract info on almost any object they don't have to be blocks.
Chris.N
2007-11-13, 08:59 PM
Which AutoCAD are you using?
In AutoCAD 2008 you can extract info on almost any object they don't have to be blocks.
he want's auto-tagging reverse populated from a table... (similar to revit capabilities)
Capt. Computer Crasher
2007-11-14, 02:27 PM
he want's auto-tagging reverse populated from a table... (similar to revit capabilities)
then yes he will need a macro or Revit I guess data extractor alone won't do it automacally anyway, he could add a column if there was a mathimatically equation for what he wanted but if its text strings then no.
james.126519
2007-11-14, 02:33 PM
how come nobody is giving me the answer i want??
Im going to tell all of you what my boss is always telling me! There are no problems, only solutions! lol
ah well, i appreciate all the input everyone. Theres always the old way i have always done it, by hand lol :)
thanks again!
Chris.N
2007-11-14, 02:39 PM
how come nobody is giving me the answer i want??
Im going to tell all of you what my boss is always telling me! There are no problems, only solutions! lol
ah well, i appreciate all the input everyone. Theres always the old way i have always done it, by hand lol :)
thanks again!
my boss' version is this: It's not a problem, it's an opportunity!
glad to see you have a sense of humor about your 'opportunities', ya need it to stick with these DB's... :beer:
wroebuck
2007-11-19, 03:59 PM
There are free lisp routines to globally edit attributes. "-attedit" is a stock AutoCAD command that will allow you to edit multiple attributes in drawing files. It just has a lot of questions to answer. Maybe it could be a possibility?
Mr Cory
2007-11-20, 06:28 PM
I found a lisp (http://forums.augi.com/showthread.php?t=71230)yesterday that will automatically number attributes as the 'tag' block is inserted into the drawing. You might be able to modify it to suit the parts number e.g. prefix suffix etc
rstrandmark
2007-11-20, 06:36 PM
I made a vba routine for you to use.
Download the two attachments. Open the dwg. Type vbaman. Press Load button, navigate to where you put the attached dvb file and load it.
Now there is an event handler for editing a table running. If you edit a table, it checks if the cell that resides at row #1, column #3 has a value of "PARTMARK". (Tables' rows & columns are zero based in vba). If it does, then looks at the length & extrusion value for each row, finds the blocks that are named the extrusion (ex. "A") that has a linear parameter named "LENdistance" the has the length listed in the table. If it finds matches to the criteria, it then changes the attribute reference with the tag "PARTMARK" within these specific blocks to the value in the table.
Here is the code that is in the DVB file that goes in the "ThisDrawing" module. You don't need to copy this to anywhere, as it's already in the DVB file. It's just so you can see what is in the code.
'~~~~~~start code~~~~~
Dim tblRef As AcadTable
Dim colHdr As String 'table identifier
Dim rowNum As Integer, colNum As Integer ' table identifier
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
rowNum = 1: colNum = 3 'where to find identifier
colHdr = "PARTMARK" 'value of identifier
If CommandName = "TABLEDIT" Then
If tblRef.GetCellValue(rowNum, colNum) = colHdr Then
Call chngBlks(tblRef)
End If
End If
Set tblRef = Nothing
End Sub
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
If TypeName(Object) = "IAcadTable2" Then
Set tblRef = Object
End If
End Sub
Sub chngBlks(defTable As AcadTable)
Dim ent As AcadEntity
Dim i As Integer, j As Integer, k As Integer
Dim pkPnt As Variant, attRefs As Variant, _
dynProps As Variant
Dim attTag As String, dynPropName As String, _
blkRefName As String, blkPartID As String
Dim blkLen As Double
Dim dataRow As Integer, lenCol As Integer, _
blkNameCol As Integer, pmarkCol As Integer
Dim BlockRef As AcadBlockReference
Dim attRef As AcadAttributeReference
dataRow = 2: lenCol = 1 'change these to match your table
blkNameCol = 2: pmarkCol = 3 'change these to match your table
dynPropName = "LenDistance" 'change this to match your block parameter name
attTag = "PARTMARK" 'change this to match your block attribute tag
For i = dataRow To (defTable.Rows - 1)
blkRefName = defTable.GetCellValue(i, blkNameCol)
blkLen = defTable.GetCellValue(i, lenCol)
blkPartID = defTable.GetCellValue(i, pmarkCol)
For Each ent In ThisDrawing.ModelSpace
If ent.ObjectName = "AcDbBlockReference" Then
Set BlockRef = ent
If BlockRef.EffectiveName = blkRefName Then
attRefs = BlockRef.GetAttributes
dynProps = BlockRef.GetDynamicBlockProperties
For j = LBound(dynProps) To UBound(dynProps)
If dynProps(j).PropertyName = dynPropName Then
If dynProps(j).Value = blkLen Then
For k = LBound(attRefs) To UBound(attRefs)
If attRefs(j).TagString = attTag Then
attRefs(j).TextString = blkPartID
End If
Next k
End If
End If
Next j
End If
End If
Next ent
Next i
Set BlockRef = Nothing
End Sub
'~~~~end code~~~~
Oh btw, thanks for giving me something to do today. I was bored out of my skull with nothing to do. Damn economy.
james.126519
2007-11-24, 12:02 AM
maybe i am doing something wrong, but this is what happens when i try to edit the table. see the attached screen shot. btw, i really appreciate this!
rstrandmark
2007-11-24, 03:39 AM
I thought you were on 2008, works well on mine. It may be a simple fix, but I don't have 2007 to test. I added some code that I suspect will make it work in the attached dvb. Use vbaman command and unload the previous one if you have it loaded. Don't dual load different versions of this dvb or it will probably crash.
I can probably guess where the code fails. If you hit the debug button when that happens it most likely will show where the code fails. A screenshot of that would be helpful. To get out of debug mode press the stop button (black square button) on the top toolbar in the vba editor.
In this code below, I added the text in red. The black bold italicized text is where I think it fails due to your version returning a different object name. Could be AcadTable, IAcadtable, or something like that. If the attached dvb does not solve the problem, and it still fails on this section of code, please go into the code by hitting the debug button, hit the vba editor stop button, Find the code (shown below) and remove the beginning apostrophe from the red colored debug line below. Try to edit a table again letting it error again, then debug, in the vba editor look in the immediate window, scroll through, there will be hundred-or-so object modified events just for clicking into a table cell, but only one or two will correspond with the table object per event trigger, need to know what that table object type is called.
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
rowNum = 1: colNum = 3 'where to find identifier
colHdr = "PARTMARK" 'value of identifier
If CommandName = "TABLEDIT" Then
If Not tblRef Is Nothing Then
If tblRef.GetCellValue(rowNum, colNum) = colHdr Then
Call chngBlks(tblRef)
End If
End If
End If
Set tblRef = Nothing
End Sub
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
'Debug.Print TypeName(Object)
If TypeName(Object) = "IAcadTable2" or TypeName(Object) = "AcadTable" Then
Set tblRef = Object
End If
End Sub
Anyway, hope it works.
One thing I should note, I polar arrayed several thousands of your blocks and edited via this code and there were some blocks that were rotated at a certain angle that did not get updated by the code. If you move or rotate these offenders, then they work with the vba code. Unexplainable.
james.126519
2007-11-24, 01:25 PM
I thought you were on 2008, works well on mine. It may be a simple fix, but I don't have 2007 to test. I added some code that I suspect will make it work in the attached dvb. Use vbaman command and unload the previous one if you have it loaded. Don't dual load different versions of this dvb or it will probably crash.
I can probably guess where the code fails. If you hit the debug button when that happens it most likely will show where the code fails. A screenshot of that would be helpful. To get out of debug mode press the stop button (black square button) on the top toolbar in the vba editor.
In this code below, I added the text in red. The black bold italicized text is where I think it fails due to your version returning a different object name. Could be AcadTable, IAcadtable, or something like that. If the attached dvb does not solve the problem, and it still fails on this section of code, please go into the code by hitting the debug button, hit the vba editor stop button, Find the code (shown below) and remove the beginning apostrophe from the red colored debug line below. Try to edit a table again letting it error again, then debug, in the vba editor look in the immediate window, scroll through, there will be hundred-or-so object modified events just for clicking into a table cell, but only one or two will correspond with the table object per event trigger, need to know what that table object type is called.
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
rowNum = 1: colNum = 3 'where to find identifier
colHdr = "PARTMARK" 'value of identifier
If CommandName = "TABLEDIT" Then
If Not tblRef Is Nothing Then
If tblRef.GetCellValue(rowNum, colNum) = colHdr Then
Call chngBlks(tblRef)
End If
End If
End If
Set tblRef = Nothing
End Sub
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
'Debug.Print TypeName(Object)
If TypeName(Object) = "IAcadTable2" or TypeName(Object) = "AcadTable" Then
Set tblRef = Object
End If
End Sub
Anyway, hope it works.
One thing I should note, I polar arrayed several thousands of your blocks and edited via this code and there were some blocks that were rotated at a certain angle that did not get updated by the code. If you move or rotate these offenders, then they work with the vba code. Unexplainable.
Well I cant seem to make anything happen now.
Let me explain what I did step by step and tell me if I missed something.
1. i created a new drawings
2. i loaded the latest code
3. i inserted a couple of the blocks
4. i ran EATTEXT and created the table, formatted in the same way it was in the drawings you sent me.
5. i filled in the blanks in column 4 with part marks
nothing happened, so i tryed regen, regenall, etc. the blocks did not update with any marks? also, no error code for the VBA?
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.