Jump to content

attribute changes value to match dwg name


Recommended Posts

Posted

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?

ID Bubble.JPG

Posted (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 by SLW210
IM A MORON
Posted

totally doable. I have VBA code for both if your interested

Posted

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

Posted

Yes I would be interested in the VBA code for both

Thanks, it will save some time. :roll:

Posted

what is your block name and tag name, and I will put together a short routine to test

Posted

Block name "DT-IDLABEL" and tag name "DNO#".

Posted

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

  • 3 years later...
Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...