Section Properties Program

Section Properties Program

andrewdroth
Advisor Advisor
1,260 Views
10 Replies
Message 1 of 11

Section Properties Program

andrewdroth
Advisor
Advisor
I spend a lot of time making drawings of custom section profiles for engineers. These drawings are usually an HSS or W beam shape with a plate welded on it.

I would like to automate the process with VBA, but it's been a while since I've done any programming.

I would like to know if the following procedures are something that can be easily done using VBA. I have enough experience that I feel comfortable doing this, I just don't want to get started and find out one of the things I thought could be accomplished can't be.

Creating Custom Section Properties Print-Outs

- User will create closed section profile of desired shape.
- User will run VBA program.

Functions

- Region all elements.
- If two or more regions are the result it will perform the ‘Subtract’ command.
- The first selection will select the largest region based on area.
- The second selection will select remaining regions.
- Retrieve centriod information of resulting region and move to origin.
- Select and copy the information from the ‘massprop’ command.
- Create text box on top left corner of Paper Space, paste massprop info.
- Make existing viewport in Paper Space zoom to extents.
- Possibly place C.O.G. block on origin. (not necessary)


Any example code would also be apprieciated.

Thanks in advance.

Andrew Roth
rothmech.com

YouTube IconLinkedIn Icon


IV2025 Pro
Apple IIe Workstation
65C02 1.023 MHz, 64 KB RAM
Apple DOS 3.3
0 Likes
1,261 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
If you've looked around, you won't see much in the way of code for sections. At least for me, it was so much work that I shelved it.

The problem(s) I ran into were as follows:

Using the "section" command, there is no way to tell if you have geometry that is both in front of, and behind, other geometry, at the same time - for example, an iso viewof a 1" long bolt running thru a 1/4" plate. One side of that bolt will be erased, where both sides of the bolt should show, one side being partially hidden.

There is no access to the solids to infer your own hidden face determination routines, you dont know where in 3d space your 2d region used to refer to.

The "section plane" command is basically useless, at least in my experience- while it will return valid geometry on curved, angled, and hidden faces, the VBA version only works on one solid at a time, while the user interface version lets you select multiple solids for true hidden faces. if you have more than one solid, you can end back up at the same issue I mentioned first.

Maybe if your application is always used under very limited conditions, you will never run into the problems I saw, however, i've found that using the words "always" and "never", when it comes to coding, eventually get you into trouble.

If you are wanting only an orthagonal section, of a solid, that doesnt have to deal with hidden line removal, arent you already doing that very thing by just having the users draw closed 2d shapes? cant the same be accomplished with a trim command on closed polylines?

What you're looking to do sounds like a major undertaking, to me. I would stick with using sections/regions, stay away from using section planes, and from the outset, evaluate the worst case conditions you'll be looking into. Nothing like having 6 months of work go down the tubes one week after your company introduces a new product that has tapers, or fillets, etc, etc...
0 Likes
Message 3 of 11

andrewdroth
Advisor
Advisor
I'm talking about 2D geometry only.

The user will create a section of the member in question manually (with lines, arcs, steel shapes, ect.) then run the program. The program just need to turn those lines into a region were massprops can be calculated and fed into a drawing for printing.

I think we are talking about two different scenarios.

Andrew Roth
rothmech.com

YouTube IconLinkedIn Icon


IV2025 Pro
Apple IIe Workstation
65C02 1.023 MHz, 64 KB RAM
Apple DOS 3.3
0 Likes
Message 4 of 11

Anonymous
Not applicable
this sounds quite possible with vba, do you have a sample drawing you'd like to post?
0 Likes
Message 5 of 11

andrewdroth
Advisor
Advisor
This is a good example of what I would commonly be using this for. Finding the massprops of a steel w beam with a plate welded on the side.

Andrew Roth
rothmech.com

YouTube IconLinkedIn Icon


IV2025 Pro
Apple IIe Workstation
65C02 1.023 MHz, 64 KB RAM
Apple DOS 3.3
0 Likes
Message 6 of 11

Anonymous
Not applicable
i failed to mention that i use 2004 😞 can anyone export as 2004 and post it?

tx
0 Likes
Message 7 of 11

andrewdroth
Advisor
Advisor
Sorry about that

Andrew Roth
rothmech.com

YouTube IconLinkedIn Icon


IV2025 Pro
Apple IIe Workstation
65C02 1.023 MHz, 64 KB RAM
Apple DOS 3.3
0 Likes
Message 8 of 11

Anonymous
Not applicable
ok, forgive my ignorance..i use the civil aspect of autocad. The drawing shows a polyline within a polyline. The lines in the drawing can be converted into regions and the inner one subtracted out of it. You had mentioned a massprop (something i'm not familiar with, but a SendCommand could take care of that). How should the 2d be converted in 3d?
0 Likes
Message 9 of 11

Anonymous
Not applicable
hmm bizarrre Message was edited by: cadger
0 Likes
Message 10 of 11

Anonymous
Not applicable
The information returned by the MassProp command is available to VBA directly through the appropriate property, i.e., objRegion.Centroid, objRegion.PrincipalMoments, objRegion.ProductOfInertia, etc.
0 Likes
Message 11 of 11

Anonymous
Not applicable
ah didn't know that, thanks

i took an easy way out and converted the lines into polylines first. maybe the following could help you get started

Sub sample()
Dim sset As AcadSelectionSet
Dim myLargeRegion As Variant
Dim mySmallRegion As Variant
Dim myLargeRegionParts(0) As AcadEntity
Dim mySmallRegionParts(0) As AcadEntity
Dim myRegion As AcadRegion
Dim myMText As AcadMText
AppActivate Application.Caption
ThisDrawing.ActiveSpace = acModelSpace
On Error Resume Next
ThisDrawing.SelectionSets.Item("sset").delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("sset")
sset.SelectOnScreen
If sset(0).area > sset(1).area Then
Set myLargeRegionParts(0) = sset(0)
Set mySmallRegionParts(0) = sset(1)
Else
Set myLargeRegionParts(0) = sset(1)
Set mySmallRegionParts(0) = sset(0)
End If
myLargeRegion = ThisDrawing.ModelSpace.AddRegion(myLargeRegionParts)
mySmallRegion = ThisDrawing.ModelSpace.AddRegion(mySmallRegionParts)
myLargeRegion(0).Boolean acSubtraction, mySmallRegion(0)
''''''''
ThisDrawing.SelectionSets.Item("sset").delete
Set sset = ThisDrawing.SelectionSets.Add("sset")
sset.Select acSelectionSetLast

'from the help file
Dim ucsObj As AcadUCS
Dim currUCS As AcadUCS

' Get the current saved UCS of the active document. If the current UCS is
' not saved, then add a new UCS to the UserCoordinateSystems collection
If ThisDrawing.GetVariable("UCSNAME") = "" Then
' Current UCS is not saved so get the data and save it
With ThisDrawing
Set currUCS = .UserCoordinateSystems.Add( _
.GetVariable("UCSORG"), _
.Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _
.Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _
"OriginalUCS")
End With
Else
Set currUCS = ThisDrawing.ActiveUCS 'current UCS is saved
End If

Set myRegion = sset(0)
Dim Centroid3dPt(0 To 2) As Double
Centroid3dPt(0) = myRegion.Centroid(0)
Centroid3dPt(1) = myRegion.Centroid(1)
Centroid3dPt(2) = 0

myRegion.Move Centroid3dPt, currUCS.origin


ThisDrawing.ActiveSpace = acPaperSpace

Dim textInsPt(0 To 2) As Double
textInsPt(0) = 0
textInsPt(1) = 9.66
textInsPt(2) = 0
Set myMText = ThisDrawing.PaperSpace.AddMText(textInsPt, 5, "Moment of Inertia X: " & myRegion.MomentOfInertia(0) & vbcr_)

' etc for other properties and formatting

ThisDrawing.SelectionSets.Item("sset").delete
End Sub
0 Likes