Jump to content

Recommended Posts

Posted

I have some dimensions in an existing drawing which I want to add a text override to using VLISP. In studying and searching for a method to do this I keep finding code which will ask the user to select the dimensions or entlast or it will use the (ssget "_X") method to select all the dimensions. Neither of which works for my project.

 

I have a method of identifying the properties and methods of the dimensions I'm interested in and one of those properties identified is the handle, which I would hope would be a good field to use as this program will be run many times and I need the property relating to the dimension to remain static over time.

 

OK, so here is what I have thus far and I have been able to get this to insert the text override but it's not using the method I want:

 

(defun C:fixit ()
 (vl-load-com)
 (setq SelSet (ssget "_X" '((0 . "DIMENSION"))))
 (setq Ent (ssname SelSet 0))
 (setq Obj (vlax-ename->vla-Object Ent))
 (vlax-put-property Obj "TextOverride" "This is the DOR Text")
)

For the moment at least, this is easy to use because the drawing I'm testing it on has only one dimension. The drawings I need this to work on have many dimensions and of those I will only be interested in 4 or 5 of them. So my plan is to use a quick snippet which will let me identify something unique and static about those 4 or 5 dimensions (individually, of course) and then write a line of code for each on which will insert the text override needed for each one. Each text override for each dimension will be different. It will not be a shotgun blast to override all of them with the same text. Thus the need for the individual line for each dimension.

 

The code I use to identify the properties of the dimensions will be a stand alone which I run once on the drawing's dimensions. Once I have something unique identified about the dimensions needed, I will set this code aside and the main program will be the one which runs and makes the changes. As I work with new drawings, this separate code will be used again but only to quickly get a name of identifier for the dimensions which can be used in the main code. Hope I've explained this clearly.

Posted

The confusion on my part is how to get the information I know about this dimension to work in that line of code which writes the override. I can see from using the command prompt:

 

Command: !Obj

#

 

But if I enter that information like this:

 

(vlax-put-property <VLA-OBJECT IAcadDimAligned 0a6dd67c> "TextOverride" "This is the DOR Text")

of course this does not work.

Posted

BINGO:

 

It works, and works quite well. I know I sound crazy but I knew this could be done. It had to be otherwise I would be looking pretty stupid come Monday morning because they told me it couldn't be done.

 

In a nutshell, this snippet allows me to individially select the dimensions objects and dump the properties to the text window. I quickly jot down the handle for each dim object and then this program gets put away. It has nothing to do with the main code which the users run when they launch the Excel VBA code. But I included it here to maybe help others and maybe to explain why I sound so crazy.

(defun C:HaveaDump ( / ent) ; Code plagerized from afralisp.net
 (vl-load-com)
   (while
       (setq ent (entsel))
       (vlax-dump-object (vlax-Ename->Vla-Object (car ent)) T)
     );while
   (princ)
)

Remember, after I write down the handles for the dim objects I want, the above code gets shut down and put away. It is not used at all in the main code I'm developing.

 

Then this little snippet will be added to the main code and it will take care of the dimtext overrides I need. Now to figure out when there is a fraction in the number and add formatting for diagonally stacked fractions. You metric system users have us yanks beat on that point.

(defun C:fixit ()
 (vl-load-com)
 (vlax-put-property (vlax-ename->vla-Object (handent [color=blue]"1AF"[/color])) "TextOverride" "DIM 1 OvrRd")
 (vlax-put-property (vlax-ename->vla-Object (handent [color=blue]"20A"[/color])) "TextOverride" "DIM 2 OvrRd")
 (vlax-put-property (vlax-ename->vla-Object (handent [color=blue]"1EE"[/color])) "TextOverride" "DIM 3 OvrRd")
 (vlax-put-property (vlax-ename->vla-Object (handent [color=blue]"1FC"[/color])) "TextOverride" "DIM 4 OvrRd")
)

 

The blue letters are the handles I got by using the Havedump code above.

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...