edit attribute definitions of all blocks in a drawing

edit attribute definitions of all blocks in a drawing

cadman777
Advisor Advisor
1,316 Views
10 Replies
Message 1 of 11

edit attribute definitions of all blocks in a drawing

cadman777
Advisor
Advisor

Hi All,

Today I have a challenge that I need help solving.

When Inventor exports to DXF, the fonts export as blocks (fonts inside blocks).

Also, the font text is txt.shx.

The titleblock exports with the attributes definitions having the font txt.shx.

The main thing I want to do at this point is to:

1. change all the attribute definitions' properties in the titleblock to be .75 width

2. change all the text width in all the blocks to .75.

Is there an easy way to do this?

Thanks...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Accepted solutions (2)
1,317 Views
10 Replies
Replies (10)
Message 2 of 11

pendean
Community Legend
Community Legend

@cadman777 wrote:

Hi All,

Today I have a challenge that I need help solving.

When Inventor exports to DXF, the fonts export as blocks (fonts inside blocks).

Also, the font text is txt.shx.

The titleblock exports with the attributes definitions having the font txt.shx.

The main thing I want to do at this point is to:

1. change all the attribute definitions' properties in the titleblock to be .75 width

2. change all the text width in all the blocks to .75.

Is there an easy way to do this?

Thanks...


Are you asking over here to get INVENTOR forum to do all of this at export time?

 

Or are you wanting AutoCAD to open those DXF files all the time with your parameters, regardless of whether you save or not?

Or are you wanting to import the DXF files into AutoCAD, saveas to DWG, and make all of these changes in an automatic way like the way INSERT command would do with your DXF(s) when going into a template with all of the STYLE settings you asked about for example?

0 Likes
Message 3 of 11

paullimapa
Mentor
Mentor
Accepted solution

if you're referring to making the width factor changes to the Title Block Attributes when opened in AutoCAD, here's a lisp routine UpdAttWid to take care of that (change wdf 0.75 to a different value as needed):

(To load: Save as UpdAttWid.lsp, drag+drop file onto AutoCAD's drawing area, enter at the command line: UpdAttWid)

; UpdAttWid update attbribute width factor within blocks
; OP:
; https://forums.autodesk.com/t5/autocad-forum/edit-attribute-definitions-of-all-blocks-in-a-drawing/m-p/12379697/thread-id/1119339
(defun c:UpdAttWid (/ lst ttb wdf)
 (setq wdf 0.75) ; change width factor value as needed
 (vl-load-com)
 (while (not ttb)
  (princ"\nSelect Block with Attributes to Change Width Factors:")
  (if (setq ttb (ssget "_+.:E:S" (list '(0 . "INSERT") '(66 . 1))))
   (progn 
    (setq lst (vlax-invoke (vlax-ename->vla-object (ssname ttb 0)) 'getAttributes)
          len (length lst)
    )
    (foreach attobj lst
     (if (vlax-property-available-p attobj "ScaleFactor") (vla-put-scalefactor attobj wdf))
    )
    (princ(strcat"\nFound & Updated Total of [" (itoa len) "] Attributes' Width Factor to: [" (rtos wdf 2 2) "]."))
   )
   (princ"\nNo Blocks with Attributes Selected...")
  ) ; if
 ) ; while
 (princ)
) ; defun

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 11

paullimapa
Mentor
Mentor
Accepted solution

if you're referring to making the width factor changes to the Texts inside Blocks when opened in AutoCAD, here's a lisp routine UpdBlkTxtWid to take care of that (change wdf 0.75 to a different value as needed):

(To load: Save as UpdBlkTxtWid.lsp, drag+drop file onto AutoCAD's drawing area, enter at the command line: UpdBlkTxtWid)

 

; UpdBlkTxtWid update Text width factor within Blocks
; OP:
; https://forums.autodesk.com/t5/autocad-forum/edit-attribute-definitions-of-all-blocks-in-a-drawing/m-p/12379697/thread-id/1119339
(defun c:UpdBlkTxtWid (/ blks doc count len wdf)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)) count 0 len 0 wdf 0.75) ; change width factor value as needed
 (vl-load-com)
 (if (setq blks (vla-get-blocks doc)) ; get collection of block table (vla-get-count blks) = total collection
  (progn
   (vlax-for n blks ; cycl through collection
    (if (and
         (= (vla-get-IsLayout n) :vlax-false) ; don't include layout/model
         (= (vla-get-isxref n) :vlax-false) ; don't include xrefs
        )
     (progn
      (setq count (1+ count)) ; add to # of actual blocks
      (vlax-for m n
       (if (member (vla-get-objectname m) '("AcDbText"))
        (if (and 
             (vlax-property-available-p m "ScaleFactor")
             (/= wdf (vla-get-scalefactor m)) 
            ) 
         (progn
          (vla-put-scalefactor m wdf)
          (setq len (1+ len))
         ) ; progn
        ) ; if width factor
       ) ; if text
      ) ; vlax-for items within block
     ) ; progn
    ) ; if
   ) ; vlax-for blocks
   (vla-regen doc acallviewports)
   (princ(strcat"\nFound [" (itoa count) "] Blocks & Updated Total of [" (itoa len) "] Texts' Width Factor to: [" (rtos wdf 2 2) "]."))
  ) ; progn
  (princ"\nNo Blocks Found in Drawing.")
 ) ; if
 (princ)
) ; defun

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 11

cadman777
Advisor
Advisor

@pendean thanks for your questions.

I'n not sure what you mean by the last of the 3 questions/statements you made.

I hardly use Acad any more so don't know what it can/will do.

Anyways, I just export out of Inventor to DXF with all the settings that Inventor is able to do (which isn't much!).

Then I open the DXF in Acad and process it so it's good enough for sending to the steel mill for processing.

When it comes into Acad with the fonts all expanded over top of eachother, and them all blocked up, it's a royal PITA to fix, and a colossal waste of time.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 6 of 11

cadman777
Advisor
Advisor

Hey Paul,

You got it (both things)!

Thanks for posting your 2 LISP routines!

I'll try them tomorrow when I go back to work.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 7 of 11

paullimapa
Mentor
Mentor

Hope they work out for you…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 11

pendean
Community Legend
Community Legend

@cadman777 wrote:

@pendean thanks for your questions.

I'n not sure what you mean by the last of the 3 questions/statements you made.

I hardly use Acad any more so don't know what it can/will do.

Anyways, I just export out of Inventor to DXF with all the settings that Inventor is able to do (which isn't much!).

Then I open the DXF in Acad and process it so it's good enough for sending to the steel mill for processing.

When it comes into Acad with the fonts all expanded over top of eachother, and them all blocked up, it's a royal PITA to fix, and a colossal waste of time.


So there is what we regular users call the "golden rule": content already in a DWG file will replace the same named content coming in with another outside file.

 

Working with that... you create a one-time AutoCAD Template file (DWT extension, once created it never gets overwritten), inside it you set STYLE command styles your Inventor exports DWG files with to the settings you want.

So INVENTOR create a text style called BUBBA.

In your template, you will create a font style(s), using STYLE command, called BUBBA with the font you want, the font settings you want (width etc.)

pendean_0-1700086850725.png

 

When you INSERT your DXF file into it, all fonts using the style name BUBBA will change in appearance.

 

SAVEAS your DXF to with as you wish.

 

0 Likes
Message 9 of 11

cadman777
Advisor
Advisor

My template is a dwg file, not a dwt file.

Just tried it your way and made no difference.

Is it possible that the path is required to be the default install path for that Template file?

Mine is in a custome folder on another drive.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 10 of 11

cadman777
Advisor
Advisor

Thanks so much for these LISP routines!

They work like a charm.

When they run, they're instant, BAM!

I sure wish I had your coding skills.

Thanks again!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 11 of 11

paullimapa
Mentor
Mentor

Glad to have helped…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes