MakeCurrent

MakeCurrent

john.uhden
Mentor Mentor
2,308 Views
22 Replies
Message 1 of 23

MakeCurrent

john.uhden
Mentor
Mentor

As far as I can tell (in C3D 2020), the MakeCurrent command deals only with an object's layer, to make it the current layer.

Whereas my MakeCurrent AutoLisp command function (though barely into puberty) aims to set most any drawing variable to a selected object's corresponding property like...

("plinewid"  "constantwidth")

("HPName"  "PatternName")

("HPScale"  "PatternScale")

("HPAng"  "PatternAngle")

("TextStyle"  "StyleName")

("TextHeight"  "Height")

etc.

Can I get volunteers to contribute to a list of matching pairs for everything that can match?

I will then add the list to my code and publish it for free.  And the more we find, I will update periodically.

I don't want them as dotted pairs because I will probably want to (mapcar 'reverse vlist), or it should be (property variable) instead.

John F. Uhden

0 Likes
Accepted solutions (1)
2,309 Views
22 Replies
Replies (22)
Message 2 of 23

ВeekeeCZ
Consultant
Consultant

My MakeStyleCurrent

Message 3 of 23

Kent1Cooper
Consultant
Consultant

You might get a start from MakeMore.lsp [attached -- it's in various other places, but some of those will be earlier versions].  It covers a lot of object types and possible settings, though it's not absolutely comprehensive.

 

Most of the time, I would expect that when you want to set things like that, you do it because you want to Make More of the thing in question -- hence the name, and the starting of a command for you rather than only setting System Variables.  But unlike some routines that change settings, it doesn't change them back when it's done [i.e. it leaves them set as in what you're describing], because you might want to make more than one new thing of whatever kind it is.

 

Its origins far predate AutoCAD's ADDSELECTED command, and it's also better than that in several ways, particularly in that with objects that could be created in various ways, it offers options for the command to use, and it recognizes certain things and offers the most appropriate command as a default.  For example, if you pick on any Polyline, whether a rectangle or a donut or a polygon or a non-descript one or one made with SKETCH or BOUNDARY, ADDSELECTED simply starts a generic PLINE command.  But the MM command in MakeMore can identify a rectangle, and offer RECTANG as a default command name, and likewise a DONUT, and a regular POLYGON, etc., though in all cases it's offering a default but you still have the options of other Polyline-making commands to choose from.

Kent Cooper, AIA
Message 4 of 23

john.uhden
Mentor
Mentor

NICE!  Yes, I would include a similar approach for textual objects with similar but not same properties.

John F. Uhden

0 Likes
Message 5 of 23

dbroad
Mentor
Mentor

Before doing a lot of programming, consider

  • The hatch command has a match properties button.
  • There is already a laymcur on the ribbon.
  • There is already a matchprop command on the ribbon.

I wrote one in 1998 that has been great to use but given the latest incarnations of AutoCAD, the needs have diminished.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 23

john.uhden
Mentor
Mentor

That's a valuable add-on for most any AutoCAD user!

Rather than initiating a command, I was thinking of the fella wanting to hatch the interior of a building, so he doesn't have to change its properties after the fact.

I guess you could also have named it after those furry little proliferate creatures on an old Star Trek episode, Tribbles.

John F. Uhden

0 Likes
Message 7 of 23

john.uhden
Mentor
Mentor

Aw, c'mon.  Don't be a Douggy Downer.  🙂

John F. Uhden

0 Likes
Message 8 of 23

CodeDing
Advisor
Advisor

@john.uhden ,

 

I imagine it might be something similar to this? I'm sure some improvements could be made.

 

Sorry to say, but I'd rather be blunt, that I wouldn't use such a function because I hate, Hate, HATE when my system variables get changed. And if I had to run this without knowing which ones were changed, or what their default was, I'd be pretty upset. Just food for thought. Like dbroad said, MATCHPROP is very handy for something like this.

(defun GetMakeCurrentList ( / )
  (list
    ;; Layout: ("ITEMTYPE" ("SystemVariable" . #subroutineToReturnValueForSystemVariable))
    ;; The entity name will ALWAYS be passed to the subroutine ^^^^^^^
    (list "LWPOLYLINE"
          (cons "PLINEWID"
                (lambda (e / tmp)
                  (if (not (vl-catch-all-error-p
                             (setq tmp
                               (vl-catch-all-apply
                                 '(lambda (e) (getpropertyvalue e "ConstantWidth"))
                                 (list e)))))
                    tmp
                    (getvar 'PLINEWID)
                  );if
                );lambda
          );cons
    );list
    (list "HATCH" (cons "HPNAME" (lambda (e) (getpropertyvalue e "PatternName"))))
    (list "HATCH" (cons "HPSCALE" (lambda (e) (getpropertyvalue e "PatternScale"))))
    (list "HATCH" (cons "HPANG" (lambda (e) (getpropertyvalue e "PatternAngle"))))
    (list "TEXT"  (cons "TEXTSTYLE" (lambda (e) (cdr (assoc 7 (entget e))))))
  );list
);defun

(defun c:MAKECURRENT ( / e eg lyr typ var val)
  ;; Get entity from user
  (if (setq e (car (entsel "\nSelect object with properties to make current: ")))
    (progn
      (setq eg (entget e))
      ;; Every entity sets current layer
      (setq lyr (cdr (assoc 8 eg)))
      (setvar 'CLAYER lyr)
      (prompt (strcat "\nCLAYER set to: " lyr))
      ;; If entity is member of other 'MakeCurrent' items, apply function for that type of item
      (setq typ (cdr (assoc 0 eg)))
      (foreach item (GetMakeCurrentList)
        (if (eq typ (car item))
          (progn
            (setq var (caadr item))
            (setq val ((cdadr item) e))
            (setvar var val)
            (prompt (strcat "\n" var " set to: ")) (princ val)
          );progn
        );if
      );foreach
      (prompt "\nMAKECURRENT Complete.")
    );progn
  );if
  (princ)
);defun

Best,

~DD

0 Likes
Message 9 of 23

ВeekeeCZ
Consultant
Consultant

I would think that those pairs could be hundreds? Just how many are DIM properties.

Also, how would the user specify which property to apply? Are you going to do some massive DCL?!

Just can't imagine.

Edit: Thx Kent.

0 Likes
Message 10 of 23

Kent1Cooper
Consultant
Consultant

@CodeDing wrote:

.... I hate, Hate, HATE when my system variables get changed. And if I had to run this without knowing which ones were changed, or what their default was, I'd be pretty upset. ....


That's another thing about my MM command.  If you pick on something that has a non-default override property for color, linetype, linetype scale, lineweight or thickness, it sets the property/properties to match the object assuming that's what you really want, but it alerts you to which are not standard default values, and suggests resetting them after you're done Making More thing(s).  It even has, and suggests the use of, a built-in MMR command to do that resetting for you [= MakeMore Reset].

Kent Cooper, AIA
0 Likes
Message 11 of 23

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

I would think that those pairs could be hunters? Just how many are DIM properties.

....


[I assume you mean "hundreds"?]  That's one less-than-fully-comprehensive area in my MM command.  If you pick a Dimension, before calling up the command for the same variety of Dimension, it sets the Layer and Dimension Style, and matches any suppression(s) of extension and/or dimension lines.  But I didn't include any more of the myriad settings that a given Dimension could have as overrides to those defined in its Style, just because there are too many.

Kent Cooper, AIA
0 Likes
Message 12 of 23

ВeekeeCZ
Consultant
Consultant

@CodeDing wrote:

...  MATCHPROP is very handy for something like this. ...


This is a basic tool that we all use daily. But there are plenty of properties that it doesn't match.

On the other hand, there are properties that you don't want to match. Typically text rotation. Or match all props but layer. 

Have you ever changed the setting? Just curious. I think it's its the same as the selectsimilar setting and others - I better never change it because you would never remember to set it back. And then would wonder why the f*

So I have MatchTextProperties, MatchAllButLayer.... 🙂

0 Likes
Message 13 of 23

john.uhden
Mentor
Mentor

I had planned to use a different technique than @CodeDing 's example, plus my thought was to put them in a multiple_select list_box with varname and value, all preselected, allowing the user to choose which variables to make current along with "All" and "None" buttons.
Yes, the multitude of dimvars could be daunting, but with multiple_select, you can hold the shift key down and drag to easily select any number at a time.  I could also add "Include" and "Exclude" text_box filters to limit the number of candidates.  Or, I could exclude every little dimstyle property except for the dimstyle name itself.

Remember that you're going to get only so many properties as the object has, and I would think we would all vote to exclude properties like 'Coordinates and 'TextString which don't have corresponding dwgvars anyway, so no votes required.  Just to be democratic, I could decide to exclude all votes from Australia, Argentina, California, @Kent1ucky, etc. 🤓

John F. Uhden

0 Likes
Message 14 of 23

ВeekeeCZ
Consultant
Consultant
Accepted solution

I see. It looks promising... 

I'll see what I can do.

Good luck.

0 Likes
Message 15 of 23

john.uhden
Mentor
Mentor

@beekeeCZ

Thanks for the positive response.

It's too bad that there is no TextRot dwgvar, but at least I have my AlignText command function.  It's really great for upside-down dimensions (when it works).  There's a glitch that shows up sometimes when I try to align with a polyline segment nested in a block or xref.  I should probably fix it.

John F. Uhden

0 Likes
Message 16 of 23

dbroad
Mentor
Mentor

There are are approximately 92 dimension properties that are worth transferring and aren't read-only.  My philosophy is that virtually all of a dimension's properties should match the dimstyle. The only ones I change regularly are the text override to add things like "<>F.V." or "<>\XTYP" or the like, the text fill option, and changing the extension line linetype.  Otherwise, overcustomizing dimensions on a per dimension basis creates a less manageable situation later. That said, the attached offers a technique (lightly tested) of interest without forcing users to pick and choose settings. 

For most changes/overrides, I prefer using the properties palette.

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 17 of 23

Sea-Haven
Mentor
Mentor

My $0.05 I think along this theme, is an old one I dont know who wrote it so apollogise to original author.

 Posted file as its long code

0 Likes
Message 18 of 23

john.uhden
Mentor
Mentor

Thanks, Alan.

That's somewhat what I had in mind.

It's too bad that many authors don't identify their name.  It would be nice if you had a name to thank, if even only mentally.

John F. Uhden

0 Likes
Message 19 of 23

cadffm
Consultant
Consultant

MM - I can not find the right word, but google translate my 'Fleißarbeit' with: Hard work!  (I mean 'annoying long work')

😀

 

Sebastian

0 Likes
Message 20 of 23

john.uhden
Mentor
Mentor

@dbroad 

Seems as though Sebastian ( @cadffm ) dug up this year old thread.

He's from Denmark, so he probably talks like "Oh, I fivegot three tell you three crenine a dimstyle second."

I agree about dimstyles and mleaderstyles... just make them current because the knowledgeable tech shouldn't be over-modifying one dim or mleader at a time.  There must be a company standard somewhere, right?

 

John F. Uhden