Jump to content

Dimension Text Override


Bill Tillman

Recommended Posts

My project tonight includes the following:

 

Take an existing drawing with some dimensions. Have a LISP program do a text override on several of the dimensions.

 

The challenge, I can't use an ssget or anything that involves the user selecting the dimensions to be edited. I know which dimensions I want to edit but have to avoid any user input.

 

I have done a few searches, including here and found only limited information and that is only if you have the user select the dimensions they want to change. Is this impossible or is there a way to possibly identify the dimension's identification and then have the code add the text overrides accordingly?

Link to comment
Share on other sites

Lee,

 

I was looking at something like this earlier today in the Help screens. Is the _X the wildcard which grabs everything in the drawing, and then you create a list with just the dimensions. I am not sure I follow how to display the list. And I need to narrow it down to just two or three of the dozen or so dimensions that are in this drawing. Can you elaborate a little more on how this works?

 

I just found another source on this which gave the syntax like this:

 

(ssget "_X" '((0 . "DIMENSION"))) 

 

I'm not sure how this assigns a variable which I can use though. The only display I get back when I run this is:

 

 

I'm thinking that in order to narrow this down to just the dims I need I may have to manually select them and identify which part of the database they are. I'm still green on this but each object has a unique number in the database which shouldn't change from one day to the next. If I can narrow these down then I could run something like entmake on the dimension objects and do the text override or would command dimedit be even simpler?

 

I guess also I could add a couple of new layers and place each dimension I want to change in it's own layer. That would filter things down. The trouble is that there will eventually be scores of drawings to do this for and I was hoping for a routine which would be a one size fit all....!

 

So how's that "Cancer Cure" coming along....? Gotta be easier than this you'd think.

Edited by Bill Tillman
Link to comment
Share on other sites

I think I have a little something started here:

 

(defun c:testme ()
 (setq scs (ssget "_X" '((0 . "DIMENSION"))))
 (setq ct 0)
 (while (< a (sslength scs))
   (setq en (ssname scs ct))
   (setq ed (entget en))
   (setq dt (cdr (assoc 1 ed)))
   (setq ct (1+ ct))
 );while
);defun

 

But I'm not really sure what will come next.....because I'm thinking and it makes my head hurt! With this I've found there are 17 dimensions in the file and I only want to do a text override on 5 of them.

 

With this I've been able to identify the 7ffffb0a970

 

So my question is does this number always remain the same or does it change each time the drawing is accessed. There may be additions made to this drawing from time to time but that will be rare. So if this number remains the same on any given day, no matter who runs it on what machine, I could theoritically identify these numbers and use them in my attempt to change the text override on only the 5 dimensions I'm interested in. Correct???

 

It looks like if I do an entmake on DXF code 1 for the dimensions I can identify... I will have it.

 

CORRECTION: Is it the Handle field #5 which is the unique identifier which will never change about this entity that I can target on?

Edited by Bill Tillman
Link to comment
Share on other sites

OK, if it's the Handle field that I can target in on, and that looks like it, how could I go about injecting a text override into DXF code #1 into the existing Entity? I don't want to create a new dimension, I would like to just use this one. And then the question becomes, will changing this Entity's properties like this change something like it's unique identifier. If this unique identifier doesn't remain static for the life of the drawing, this will not be the ticket I'm looking for.

Link to comment
Share on other sites

Bill,

 

I recommend you add more filters to the ssget filter list to filter the set of Dimensions that is retrieved by the ssget function.

 

To answer your other questions, the entity handle is persistent between drawing sessions, the entity name is not.

 

For example, if you wanted to filter only Rotated Dimensions:

 

(ssget "_X" '((0 . "DIMENSION") (-4 . "<OR") (70 . 32) (70 . 64) (70 . 128) (-4 . "OR>")))

Or perhaps filter Dimensions based on an existing Text Override:

 

(ssget "_X" '((0 . "DIMENSION") (1 . "*?*")))

Will collect all Dimensions with a Text Override.

 

I strongly suggest you read the Visual LISP Developer Guide on Selection Set handling, section:

 

+- AutoLISP Developer's Guide
|
+--+- Using the AutoLISP Language
  |
  +--+- Using AutoLISP to Manipulate AutoCAD Objects
     |
     +--+- Selection Set Handling

 

As for adding a Text Override, consider this example:

 

(defun c:test ( / e i s )
   (if (setq s (ssget "_:L" '((0 . "*DIMENSION"))))
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i)))))
           (entmod (subst (cons 1 "Lee <> Mac") (assoc 1 e) e))
       )
   )
   (princ)
)

Link to comment
Share on other sites

Thanks. I have been reading all night and most of this morning that very book. And again the process just takes time. I am understanding more about this but when I tried some of the things I came up with there appears to still be something I'm missing.

 

I have identified the 5 dimensions I need to add the test override to and would like to come up with a short code which would allow me to select one of them and then it print the handle next to it. Once I have the handle I think I have the information needed so I can prepare the larger program to do the text override using these handles. But the examples I'm reading about all show how to use ssget or entlast which gives me entities I don't need in the list. I tried this:

 

(defun C:PRINTDXF ()
 (setq ent (entlast))   ; Set ent to last entity.
 (setq entl (entget ent))  ; Set entl to association list of last entity.
 (setq ct 0)    ; Set ct (a counter) to 0.
 (textpage)    ; Switch to the text screen.
 (princ "\nentget of last entity:")
 (repeat (length entl)   ; Repeat for number of members in list:
   (print (nth ct entl))  ; Print a newline, then each list member.
   (setq ct (1+ ct))   ; Increments the counter by one.
 )
 (princ)    ; Exit quietly.
)

 

and it worked well for the last entity. But when I tried to substitute (ssget) for entlast, it got into the loop and then crashed with and error about the wrong lintp of somekind. I'm really stuck right now as the location I'm at has no internet access unless I drag my whole setup down to the local Starbucks or McDonalds. This is supposed to be fixed for me but the IT guys are too busy to mess with the new guy right now. BTW - the eventual text override will be different for each of the 5 dimensions which is why I need to have the Handle for each of them separately.

 

Many thanks. I know I'm a real pest and I do appreciate your advice.

Link to comment
Share on other sites

Thanks. I have been reading all night and most of this morning that very book.

 

Book? To clarify, by 'Visual LISP Developer Guide' I am referring to that section in the VLIDE Help Files.

Link to comment
Share on other sites

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