Dimension an arc or circle in a block (insert) with automation.

Dimension an arc or circle in a block (insert) with automation.

JBerns
Advisor Advisor
1,485 Views
10 Replies
Message 1 of 11

Dimension an arc or circle in a block (insert) with automation.

JBerns
Advisor
Advisor

Greetings, Autodesk Community.

 

I have a function that creates a plate (rectangle) and then inserts one of three blocks based on user input.

The blocks are a hole, notch, or keyway. Each block is available in two sizes, but are not dynamic blocks.

The geometry inside the block that I am trying to access (dimension) is either a circle or an arc.

The inserts are placed at various positions on the plate, also based on user input.

 

I have been successful at automating the dimensions for length, width, hole spacing, etc.

The challenge I face is to add a dimension to the arc or circle inside the insert. The block, containing the arc/circle to be dimensioned, is encircled in the first image. The second image shows the desired dimension with actual measured value and additional text.

Plates with inserts to be dimensioned.Plates with inserts to be dimensioned. Preferred format for dimension.Preferred format for dimension.

 

  • I know I can use the DIM command to manually select the circle/arc inside the block, but I want to accomplish the dimensioning with automation.
  • I know how to get the block definition and the geometry within, but how does that translate to the inserts?
  • I would prefer to avoid dynamic blocks and visibility states.

 

I have attached a drawing for your convenience. The block names are Hole56TP, Key56, and Notch150.

 

Thanks for your time and attention. I look forward to the replies.

 

 

Kind regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
1,486 Views
10 Replies
Replies (10)
Message 2 of 11

ronjonp
Mentor
Mentor

Why don't you add this dimension option to whatever code you're using to creates these plates? If you know the name of the block is it really necessary to use a real dimension?

(cond ((wcmatch bn "HOLE56TP,Key56") "9/16 TYP.")
      ((wcmatch bn "Notch150") "1 1/2 NOTCH TYP.")
)
0 Likes
Message 3 of 11

JBerns
Advisor
Advisor

@ronjonp,

Through automation, I can create the geometry and dimensions shown with my code.

Plates_with_Inserts_Example_03.png

 

The dimension for the insert encircled above is what I cannot create yet.

I don't want the dimension to appear on every insert. Generally, the dimension is added to the first insert that is placed to the right of the left bend (phantom) line.

 

Regarding a real dimension, I just thought that if AutoCAD can find the arc/circle geometry inside a block, AutoLISP or Visual LISP should be able to also.

 

Thanks for the feedback.

 

Regards,

Jerry

 

 

I

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant

I'm probably missing something. Why is counting some point on the circle an issue? Or the second for placing the leader? That's all what _dimradius needs. 

0 Likes
Message 5 of 11

JBerns
Advisor
Advisor

@ВeekeeCZ,

 

Perhaps in this situation, it is too complicated to acquire the geometry info from the block. Based on the Insert name, I could calculate the points for the diameter dimension. I am only working with six blocks now, but that could grow in the future. Still, that shouldn't be too many IF or COND statements. In fact, it may be much less code than to pursue the block interrogation.

 

 

I remain curious how the DIM command can extract that entity info from the block.

 

Regards,

Jerry

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 6 of 11

ВeekeeCZ
Consultant
Consultant

Well, I'm pretty much confused here. 

 

Why that would be too complicated? It's not. You've said that you know how to get block's definition. So... Since the block is a static, the block's geometry is the same not matter if that's a block definition or block reference. Just a basic loop to collect all the inner circles or arcs. Sure, more challenging might be the selection of the right one to be dimension-ed.... specifically following your "the first insert that is placed to the right of the left bend (phantom) line"

 

DIM command?! Do you talk about new DIM command, new since acad 2016? Did you use that command within LISP for dimensions you already have in post #3? I highly doubt that DIM command would be any useful in LISP. Its too complicated, too responsive and new commands in general are not very friendly to LISP. I would definitely use the old good DIMRADIUS.

 

What do you even mean by "I remain curious how the DIM command can extract that entity info from the block"... Extract by what? Using just a point, or list of ename and point, or sub-ename? Did you test some of those? 

 

IMHO, since your blocks are static, I would not bother to program dimensions. How about prepare two versions of blocks, one with dimensions, the second without and do little of if's and or's... the block can be exploded while insertion.... and job's done within minutes.

 

0 Likes
Message 7 of 11

JBerns
Advisor
Advisor

@ВeekeeCZ,

 

I apologize if I have caused confusion. I was confused on how the DIMDIAMETER command was extracting the arc/circle info from the Insert. I've determined that the dimension command appears to obtain the block definition and then translates the geometry information for position, rotation, and scale.

 

I was analyzing an associative dimension, but was having difficulty making sense of the 360 and 330 group codes. From the associative info I was hoping to figure how how to make a dimension with (entmake) to avoid using (command).

 

A huge help for analyzing a complex object was some code I found by T. Willey. You can find his code here.

 

 

I tried using the DIMDIAMETER command, but would occasionally get the message, "Object selected is not a circle or arc." The object selection was effected by magnification and whether the Insert was in the view window. I would prefer to be able to create an object regardless of magnification. That means (entmake) or (vla-AddDimDiametric).

 

I would prefer not to double our block library by making two versions of the holes, notches, keys, etc. Dynamic blocks would add more complexity IMO.

 

Going forward, I have a solution to use (entmake) to create the diameter dimensions.

 

Thanks for the feedback. It is appreciated.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 8 of 11

ВeekeeCZ
Consultant
Consultant

@JBerns wrote:

... I was analyzing an associative dimension, but was having difficulty making sense of the 360 and 330 group codes. From the associative info I was hoping to figure how how to make a dimension with (entmake) to avoid using (command).

A huge help for analyzing a complex object was some code I found by T. Willey. ...

 

Hmm, *THUMBS UP* for you! Seriously!! If you were able to understand that, I wouldn't worry about you. You would figure it out eventually. Good luck!

0 Likes
Message 9 of 11

JBerns
Advisor
Advisor

Thanks, @ВeekeeCZ

 

After making dimensions with (entmake) and (vla-AddDim...) functions, one can really appreciate what happens behind the scenes with the DIM commands.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 10 of 11

roland.r71
Collaborator
Collaborator

@JBerns wrote:

 

  • I know how to get the block definition and the geometry within, but how does that translate to the inserts?

To get to the geometry, that's actually the only way to do it.

The insert is merely a reference to the definition, when it come to geometry. inserts have non (of their own).

 

So, you need to get the definition, measure the geometry and use that to dimension the inserts. (compensating for any scale, if the insert has been scaled down or up.)

0 Likes
Message 11 of 11

JBerns
Advisor
Advisor

@roland.r71,

 

Agreed. That was my understanding for Inserts, they are just a reference to the block definition.

 

Doing some earlier testing, I thought I was getting some conflicting results. The community, and now myself, have confirmed that the block definition must be used and then translate for position, rotation, and scale.

 

The code is working well now and I am programmatically creating the diameter dimensions.

 

Three viewports showing dimensions for three Insert types.Three viewports showing dimensions for three Insert types.

Incredible how much work the DIM command does for the user. You should see the amount of code it required to add just the extension arc on the notch dimension.

 

Thanks all for the feedback.

 

 

Regards,

Jerry

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes