Jump to content

Recommended Posts

Posted

I have a bit of code which adds a dimension to the drawing. Based on some other criteria in the drawing I'd like to change the color of this dimension to red to indicate to the user there are some special considerations to be made. We thought about a note but the users prefer that the color of this dimension object be a different color.

 

Ok, so I add the dimension and then try to change it's color using "CHPROP" but that's not working. Can anyone offer some advice on how to change the color of a dimension? I'll be able to use (entlast) to select it. Any by doing so I get the properties of the dimension and cheat by copying it into the IDE and formatting it. I end up with this:

 


((-1 . <Entity name: 7ffffbec3f0>)
 (0 . "DIMENSION")
 (5 . "F9867")
 (102 . "{ACAD_XDICTIONARY")
 (360 . <Entity name: 7ffffbec4d0>)
 (102 . "}")
 (102 . "{ACAD_REACTORS")
 (330 . <Entity name: 7ffffbec580>)
 (102 . "}")
 (330 . <Entity name: 7ffffb039f0>)
 (100 . "AcDbEntity")
 (67 . 0)
 (410 . "Model")
 (8 . "Dim1")
 (100 . "AcDbDimension")
 (280 . 0)
 (2 . "*D157")
 (10 -9.48943 -93.5625 0.0)
 (11 -9.48943 -90.5625 0.0)
 (12 0.0 0.0 0.0)
 (70 . 32)
 (1 . "")
 (71 . 5)
 (72 . 1)
 (41 . 1.0)
 (42 . 6.0)
 (73 . 0)
 (74 . 0)
 (75 . 0)
 (52 . 0.0)
 (53 . 0.0)
 (54 . 0.0)
 (51 . 0.0)
 (210 0.0 0.0 1.0)
 (3 . "Standard")
 (100 . "AcDbAlignedDimension")
 (13 -6.0 -87.5625 0.0)
 (14 -4.0 -93.5625 0.0)
 (15 0.0 0.0 0.0)
 (16 0.0 0.0 0.0)
 (40 . 0.0)
 (50 . 1.5708)
 (100 . "AcDbRotatedDimension")
)

 

I believe the DXF code 67 is the color, but how would I go about setting it to "Red" given that this object will the (entlast) or I will have assigned it to something using (entlast) before moving on. In the end, if certain criteria are true, I want to change this dimension's color to "Red".

Posted

???

(vla-put-color <obj> acred)

Posted

Thanks BB.. I tried this first:

 

(setq enlist(entget (entlast)))
(subst (cons 67 1) (assoc 67 enlist) enlist)

 

But that's not it. So I tried your suggestion like so:

 

vla-put-color (entlast) acred)

 

That missed the mark as well. Am I getting the syntax right in your suggestion? I'm still not very sharp on DXF codes. I was amazed at how with the first shot I was able to change the 67 value in the list, but that apparently is not for the color.

Posted

67 isn't dxf code of color (62). With Dimension, you must specify what u want to change color (text, diménsion lines, extension line, arrow .. ?), and i think u should use Visualisp in this case

 

Etc :

(vla-put-ExtensionLineColor obj 1)

(vla-put-TextColor obj 4)

...

With obj = (vlax-ename->vla-object ename_of_dimension_object) = (vlax-ename->vla-object (entlast))

 

You can find what u need more by dump dimension object :

(vlax-dump-object (vlax-ename->vla-object (car (entsel))))
Posted (edited)

Ok, I think I have it. Once the dimension is in and I can call it (entlast) or anything else...... and now for the finished product. I'm still a long way off from understanding all of the vlax and vla stuff. But this is what I've put together and it's working:

 

(defun dim_color_change (dimcolor / obj)
 (setq obj (vlax-ename->vla-object (entlast)))
 (mapcar '(lambda (x)
            (vl-catch-all-apply 'vlax-put (list obj x dimcolor))
          ) ;_ end of lambda
         '("Color"
           "DimensionLineColor"
           "ExtensionLineColor"
           "TextColor"
          )
 ) ;_ end of mapcar
 (vlax-release-object obj)
 (princ)
) ;_ end of defun

 

Thanks for the helpful pointers.

Edited by Bill Tillman
Posted

Bill,

 

You're dealing with internal Object's which do not have to be released; only external Objects (i.e., FileScriptingObject, Shell.Application, etc.) need to be released.

 

The Visual LISP extension Methods only work on Vla-Object (i.e., Vlax-Ename->Vla-Object, etc.), with exception to the Vlax-Curve* functions which also accept Ename as a valid argument.

 

The last entity added to the Database (entlast), is not always going to be your dimension... At minimum, you'll want to check that either (wcmatch (cdr (assoc 0 )) "DIM*"), or (wcmatch (strcase (vla-get-objectname )) "*DIM*"), prior to evaluating the rest of your code, IMO.

Posted

All very good points except that with my code I add the dimension and then immediately, and I mean immediately, hit the (entlast) thing. Sometimes I use (entlast) itself, other times I immediately assign (entlast) to a temp variable. Recall, that my projects for these guys are completely automated. There is no chance that a user would interrupt it or any other object be confused for (entlast). It serves me well, but only in this totally automated process can one be assured of such.

  • 11 years later...
Posted

Looking for a LSP to select a dimension in the drawing and change the color to red for any type of dimension, be it a rotated, aligned, or angular.

Posted
1 hour ago, Ashishs said:

Looking for a LSP to select a dimension in the drawing and change the color to red for any type of dimension, be it a rotated, aligned, or angular.

@Ashishs Please don't double post. See my reply in your other post.

Posted (edited)

**********************************

Moved to...💨🛩️

 

Edited by Nikon

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