cadmando2 Posted November 21, 2008 Posted November 21, 2008 I work for a HVAC Engineering company and every year the first 5 months are crazy with upgrading schools and don’t have a lot of time. So I’m always coming up with ways to make are job easier. I’m always looking for custom programs. One thing is a little time consuming is insert ID bubble and title blocks. Can an attribute that is in a block be inserted into a DWG file that one of the value’s change to match the Dwg name? Example. Creating Mechanical detail sheets. Insert ID bubble’s into Dwg file and bottom number “Value” change to match drawing number? But to be able to modified if needed! It would be great if the top value were automated to change to the next number and the bottom number “Value” would change to the DWG file. I would like to do the same thing with a title block? Insert title block and the File No value change and the drawn by Value change to the user initials. Can any one help? Quote
flowerrobot Posted November 21, 2008 Posted November 21, 2008 (edited) SORRY FOR THE RUFF CODE, ITS FRI ARVO AND TIME IS PRESSING BUT YOU GET THE PICTURE (DEFUN C:BLAH() (SETQ LO (getvar "dwgname")) (SETVAR ATTDIA 0) (COMMAND "-INSERT" FILL IN THE REST ) "" "" LO" (SETVAR ATTDIA 1) (PRINC) ) Edited January 3, 2012 by SLW210 IM A MORON Quote
CmdrDuh Posted November 21, 2008 Posted November 21, 2008 totally doable. I have VBA code for both if your interested Quote
ASMI Posted November 21, 2008 Posted November 21, 2008 It seems no need programming. Create block with attribute and change it to field: %% Simply paste blue text to attribute value. It will always show your filename. My_sample_Drawing.dwg Quote
ASMI Posted November 21, 2008 Posted November 21, 2008 Pardon. AutoCAD 2004. There isn't fields... Quote
cadmando2 Posted November 24, 2008 Author Posted November 24, 2008 Yes I would be interested in the VBA code for both Thanks, it will save some time. Quote
CmdrDuh Posted November 24, 2008 Posted November 24, 2008 what is your block name and tag name, and I will put together a short routine to test Quote
cadmando2 Posted November 24, 2008 Author Posted November 24, 2008 Block name "DT-IDLABEL" and tag name "DNO#". Quote
CmdrDuh Posted November 25, 2008 Posted November 25, 2008 Here you go, tested and it works. It will fix all of the blocks named DT-IDLABEL in a drawing to reflect the drawing name Option Explicit Public Sub DtlValUpdate() Dim strDrawingName As String, vardata(1) As Variant, intType(1) As Integer, varAtts As Variant Dim objSelSet As AcadSelectionSet, objBlockRef As AcadBlockReference, i As Integer, objAttRef As AcadAttributeReference strDrawingName = (Left(ThisDrawing.Name, (Len(ThisDrawing.Name) - 4))) intType(0) = 0 vardata(0) = "INSERT" intType(1) = 2 vardata(1) = "DT-IDLABEL" ACADSelSet objSelSet, "UPDateDtl" objSelSet.Select Mode:=acSelectionSetAll, FilterType:=intType, FilterData:=vardata For Each objBlockRef In objSelSet If objBlockRef.HasAttributes Then varAtts = objBlockRef.GetAttributes For i = LBound(varAtts) To UBound(varAtts) Set objAttRef = varAtts(i) If objAttRef.TagString = "DNO#" Then objAttRef.TextString = strDrawingName Exit For End If Next i End If Next objBlockRef End Sub Public Function ACADSelSet(funcObjSelSet As AcadSelectionSet, funcSelectionSetName As String) Dim objSelCol As AcadSelectionSets On Error GoTo Err_Control Set objSelCol = ThisDrawing.SelectionSets For Each funcObjSelSet In objSelCol If funcObjSelSet.Name = funcSelectionSetName Then funcObjSelSet.Clear funcObjSelSet.Delete Exit For End If Next Set funcObjSelSet = objSelCol.Add(funcSelectionSetName) Exit_Here: Exit Function Err_Control: Select Case Err.Number Case -2145386300 MsgBox "ACAD_Functions.ACADSelSet" & vbCrLf & Err.Number & " - " & Err.Description Case Else MsgBox "ACAD_Functions.ACADSelSet" & vbCrLf & Err.Number & " - " & Err.Description End Select End Function Quote
metozade Posted January 1, 2012 Posted January 1, 2012 Hi, Thank you for this code. reverse logic of this code, employees need. attribute value, which will make dwg file name I'm working on, but I could not do Is this possible? thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.