Calling out the dimension of the chamfer by Dimlinear!

Calling out the dimension of the chamfer by Dimlinear!

Anonymous
Not applicable
2,559 Views
26 Replies
Message 1 of 27

Calling out the dimension of the chamfer by Dimlinear!

Anonymous
Not applicable

(defun C:C1 ()

(setvar "cmdecho" 0)
(setq osm (getvar "osmode"))

(setq e (car (entsel "\nSelect chamfer:")))
(setq f (entget e))
(setq s (cdr (assoc 10 f)))
(setq s1 (cdr (assoc 11 f)))
(setvar "osmode" 0)
(command "dimlinear" "" s s1 "")
(setvar "osmode" osm)
(setvar "cmdecho" 1)
(princ)
)

-------------------

Hi,

 

I am trying to change new command for my calling chamfer dim that I have to calling out a lot of dimensions of chamfer corners everyday. I tried lisp above and it only can choose one edge and calling out dimension by one direction. I wish I can choose an area, enter and then all chamfer corners will be dimensioned by Dimlinear or Quickselect command.

 

Thank you.

 

chamfer.png

0 Likes
Accepted solutions (1)
2,560 Views
26 Replies
Replies (26)
Message 2 of 27

ВeekeeCZ
Consultant
Consultant

Search for quite a recent thread, not older than a month, that did just that.

0 Likes
Message 3 of 27

Anonymous
Not applicable

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/callout-dimension-of-a-chamfer-by-se...

 

I found this one that may be the one you mentioned, but It only choose one edge for onetime, 4 corners I have to choose 4 times. I wish there is a lisp to choose an area and all chamfer dimensions will be called out as I mentioned, It is not necessary to use Mleader or leader, I ony need to callout it by dimlinear is Ok for me. Thanks!

0 Likes
Message 4 of 27

hak_vz
Advisor
Advisor

There are some auto-dimension scripts available but I didn't find a version that would use linear dimensions. I'll try to create a script for this during the weekend.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 27

ВeekeeCZ
Consultant
Consultant

Post that image example as dwg.

0 Likes
Message 6 of 27

Kent1Cooper
Consultant
Consultant

It looks like that code is designed for Lines.  But the "" after the command name gets the "select an object" option, and it picks at one of the endpoints, and only sometimes "sees" the diagonal Line, and then it uses the other end of that Line to position the dimension line.  I get results like this [yes, I picked on the diagonal Lines]:

Kent1Cooper_0-1608292355524.png

 

That can be fixed, though how to automatically place the dimension lines outside the shape would be a real challenge.

 

But other questions arise.  Are they always Lines, never a Polyline?  And are the non-dimensioned edges always orthogonal?  Never like these?

Kent1Cooper_1-1608292688757.png

 

Kent Cooper, AIA
0 Likes
Message 7 of 27

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

Search for quite a recent thread, not older than a month, that did just that.


I assume you're referring to >this thread<, which @Anonymous refers to in Message 3, but in addition to the one-at-a-time issue, that's only for Chamfers of equal distances, and places only one label, not Dimensions in both directions.  It wouldn't handle their 10-and-20 corner.

Kent Cooper, AIA
0 Likes
Message 8 of 27

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... But other questions arise.  ....


Another one:  Are they always Chamfers between perpendicular edges?  Never something like this?

Kent1Cooper_0-1608295773819.png

 

Kent Cooper, AIA
0 Likes
Message 9 of 27

ВeekeeCZ
Consultant
Consultant

Ok, then try his one. It would DIM all non-orthogonal segments. Set distance as you like.

 

(vl-load-com)

(defun c:DimChamfers ( / e p d a b g)

  (setq d 6) ; <- distance
  
  (while (setq e (bpoly (getpoint "\nPick a point: ")))
    (setq p 0)
    (while (vlax-curve-getPointAtParam e (setq p (1+ p)))
      (if (and (setq a (vlax-curve-getPointAtParam e (1- p)))
	       (setq b (vlax-curve-getPointAtParam e p))
	       (setq g (angle a b))
	       (not (equal (rem (+ 0.01 g) (/ pi 2)) 0. 0.02))
	       )
	(cond ((< g (* 0.5 pi))
	       (command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 1.5 pi) d)
			"_.dimlinear" "_non" a "_non" b "_v" (polar b 0. d)))
	      ((< g pi))
	       (command "_.dimlinear" "_non" a "_non" b "_v" (polar a 0 d)
			"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 0.5 pi) d)))
	      ((< g (* 1.5 pi))
	       (command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 0.5) d)
			"_.dimlinear" "_non" a "_non" b "_v" (polar b pi d)))
	      (T
	       (command "_.dimlinear" "_non" a "_non" b "_v" (polar a pi d)
			"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 1.5 pi) d))))))
    (command "_.erase" e "")
    )
  (princ)
  )

 

Message 10 of 27

Anonymous
Not applicable

chamfer.png

It will be great if we can do as fig. above, for acute angle & obtuse angle, we will draw the lines with different layer and use dimlinear for dimensioning. My purpose is calling out all chamfer corners by choose an area, the lisp will reconize the corners and automatically call out all dimensions.I alsmost use the lines (LWpolylines,I do not use)

0 Likes
Message 11 of 27

Anonymous
Not applicable

Thank you, I am waiting for your reply soon....

0 Likes
Message 12 of 27

Anonymous
Not applicable

I tested but it only created a polyline and overlap with the current lines...then it say that: Analyzing the selected data...
Analyzing internal islands; error: syntax error.

0 Likes
Message 13 of 27

Anonymous
Not applicable

For acute angle & obtuse angle, we will draw the lines with different layer and use DIMALIGNED for dimensioning!

0 Likes
Message 14 of 27

hak_vz
Advisor
Advisor
Accepted solution

@AnonymousSince @ВeekeeCZ solutuion is on a line what I wanted to post, here is his code

that would now have to work correctly. It may need some additional touches to handle some

special situations, but it's OK.

 

(defun c:DimChamfers ( / e p d a b g)
(setq d 10) ; <- distance
(while (setq e (bpoly (getpoint "\nPick a point inside object > ")))
(setq p 0)
(while (vlax-curve-getPointAtParam e (setq p (1+ p))) 
(if (and
(setq a (vlax-curve-getPointAtParam e (1- p)))
(setq b (vlax-curve-getPointAtParam e p))
(setq g (angle a b))
(not (equal (rem (+ 0.01 g) (/ pi 2)) 0. 0.02))
)
(cond 
((< g (* 0.5 pi))(command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 1.5 pi) d)
"_.dimlinear" "_non" a "_non" b "_v" (polar b 0. d))
)
((< g pi)
(command "_.dimlinear" "_non" a "_non" b "_v" (polar a 0 d)
"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 0.5 pi) d))
)
((< g (* 1.5 pi))(command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 0.5) d)
"_.dimlinear" "_non" a "_non" b "_v" (polar b pi d)))

(T(command "_.dimlinear" "_non" a "_non" b "_v" (polar a pi d)
"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 1.5 pi) d)))
)
)
)
(command "_.erase" e "")
)
(princ)
)

@ВeekeeCZYou produced good code as always, sorry for my intervention.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 15 of 27

ВeekeeCZ
Consultant
Consultant

@hak_vz 

 

Thanks. I don't like this method much but it seemed to have some advantages in this case...

Anyway, do what you please to do with this. I'm off for obvious reasons.

0 Likes
Message 16 of 27

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

It will be great if we can do as fig. above, for acute angle & obtuse angle, we will draw the lines with different layer and use dimlinear for dimensioning. My purpose is calling out all chamfer corners by choose an area, the lisp will reconize the corners and automatically call out all dimensions.I alsmost use the lines (LWpolylines,I do not use)


For one thing, it would need to be DIMALIGNED or possibly DIMROTATED, not DIMLINEAR, which dimensions only in horizontal and vertical directions.


In any case, what you describe becomes hugely more complicated.  It would be a lot easier if you used Polylines, because a routine would have some way of deciding which edges to consider in relation to each other, and because it would have some basis for putting the dimension line locations on the outside.

 

As a start, see >this< on that other thread for something that finds the virtual intersection between two selected edges, and determines the Chamfer distances from there to the near ends of those edges.  But that requires picking on the two edges involved.  If you select a bunch of independent Lines together, a routine would have a daunting challenge [if it's even possible] to decide which are the "main" sides and which are the chamfered corners.  A Polyline at least has them in an order such that it could look at edges that are two segments apart.

 

Other questions arise:

 

Would all the chamfered corner pieces always be shorter than all the "main" edges?  Since it would not be able to limit consideration to edges that are not orthogonal, the length comparison could be crucial to deciding which are the chamfered edges.

 

By the wording "choose an area," are you picturing picking within an area, or selecting the Lines that define it [or a Polyline that defines it, if you change to using those]?  If by picking within an area, a routine would almost certainly use BOUNDARY or BPOLY to draw a Polyline to work with, anyway.

Kent Cooper, AIA
0 Likes
Message 17 of 27

Anonymous
Not applicable

Thank you very much @ВeekeeCZ & @hak_vz , It can be applied for my job but can not use for the acute angle & obtuse angle, and it does not works when WCS is changed to UCS, I have to transfer UCS back to WCS, So It could be:

--------------------------------

(defun c:DimChamfers ( / e p d a b g)

(command "._undo" "_begin")
(command "ucs" "w")
(setvar "cmdecho" 0)
(setq d 10) ; <- distance
(while (setq e (bpoly (getpoint "\nPick a point inside object > ")))
(setq p 0)
(while (vlax-curve-getPointAtParam e (setq p (1+ p)))
(if (and
(setq a (vlax-curve-getPointAtParam e (1- p)))
(setq b (vlax-curve-getPointAtParam e p))
(setq g (angle a b))
(not (equal (rem (+ 0.01 g) (/ pi 2)) 0. 0.02))
)
(cond
((< g (* 0.5 pi))(command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 1.5 pi) d)
"_.dimlinear" "_non" a "_non" b "_v" (polar b 0. d))
)
((< g pi)
(command "_.dimlinear" "_non" a "_non" b "_v" (polar a 0 d)
"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 0.5 pi) d))
)
((< g (* 1.5 pi))(command "_.dimlinear" "_non" a "_non" b "_h" (polar a (* 0.5) d)
"_.dimlinear" "_non" a "_non" b "_v" (polar b pi d)))

(T(command "_.dimlinear" "_non" a "_non" b "_v" (polar a pi d)
"_.dimlinear" "_non" a "_non" b "_h" (polar b (* 1.5 pi) d)))
)
)
)
(command "_.erase" e "")
)
(setvar "cmdecho" 1)
(command "._undo" "_end")
(princ)
)

 

-----------------------

But After UCS-->WCS, I want to get back to my current UCS, how can I do? we can use "Trans" for it?

0 Likes
Message 18 of 27

Anonymous
Not applicable

In my drawings, We always have to set the drawings by lines, Therefore, We can use command "Pedit" to convert to Polylines, and the last routine we insert "explode" for it to get them back to lines?

0 Likes
Message 19 of 27

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... But After UCS-->WCS, I want to get back to my current UCS, how can I do? we can use "Trans" for it?


(command "_.ucs" "_previous")

Kent Cooper, AIA
0 Likes
Message 20 of 27

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... We can use command "Pedit" to convert to Polylines, and the last routine we insert "explode" for it to get them back to lines?


Yes, that can be done.  Now, an answer to the first of my "Other questions"....

Kent Cooper, AIA
0 Likes