make centermark with Ilogic

make centermark with Ilogic

Darkforce_the_ilogic_guy
Advisor Advisor
3,186 Views
25 Replies
Message 1 of 26

make centermark with Ilogic

Darkforce_the_ilogic_guy
Advisor
Advisor

I am trying to make some automation to making drawing and working on an illogic code to add Center mark to an drawing.

 

So far I can get it to centermart circular holes and all view..

 

The problem I still have that 

 

if I run the code again .. it will add one more centermark even if there already are one

 

the second thing.. is that I do not want one on my ISO view.

 

my code so far is like this

 

Sub main
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

Dim oView As DrawingView

 


For y = 1 To oSheet.DrawingViews.Count
 oView = oSheet.DrawingViews.Item(y)
Dim oCenterMarks As Centermarks
oCenterMarks = oSheet.Centermarks

 


Dim aoDrawCurves4 As DrawingCurve
oDrawViewCurves = oView.DrawingCurves(aoEdge4)
Dim aoDrawCurves4Count = oDrawViewCurves.Count

For i=1 To aoDrawCurves4Count
 

aoDrawCurves4 = oDrawViewCurves.item(i)

Dim oDim2 As Centermark

Try
 If aoDrawCurves4.CurveType.ToString = "kCircleCurve" Then
oDim2 = oCenterMarks.Add(oSheet.CreateGeometryIntent(aoDrawCurves4))
End If
Catch
 
End Try
Next
Next


End Sub

 

 

 

0 Likes
Accepted solutions (3)
3,187 Views
25 Replies
Replies (25)
Message 2 of 26

chandra.shekar.g
Autodesk Support
Autodesk Support

@Darkforce_the_ilogic_guy ,

 

Can you please provide non confidential data and screenshot of centermark which is created manually or UI?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 26

admaiora
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy   did you solved?

 

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

_____________________________________________________________________________
Facebook | Twitter | Youtube

Message 4 of 26

Darkforce_the_ilogic_guy
Advisor
Advisor

No not jet. but have not have much time to working on this project.

 

I have been working on printe all drawing to PDF with add Draft on the drawing. have been working on an ilogic that set Create date on Custom Centent center file to today date , and make an Ilogic script that emtry the Browser note(Display Name) .. with we have hade problem that the browser name get Lock(override) to it will still have the old name in the browser note if you rename or copy it later.

 

have also been working on an ilogic code that give me a list over the drawing(2d) that are not made jet... we do not make all drawing but made an AI that can see with ones that need an drawing. there still do not have one

0 Likes
Message 5 of 26

tdant
Collaborator
Collaborator
Accepted solution

This got a little more convoluted than I expected, as there were several edge cases to be avoided, but here's your rule, rewritten to address your two concerns:

 

Sub main()
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisDoc.Document
    
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oView As DrawingView
    
    For y = 1 To oSheet.DrawingViews.Count
         oView = oSheet.DrawingViews.Item(y)
         
         ' Only apply center marks to cardinal orthographic views
         If oView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation Or _
			 oView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoBottomRightViewOrientation Or _
			 oView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopLeftViewOrientation Or _
			 oView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation Then GoTo NextView
       
        Dim oCenterMarks As Centermarks
        oCenterMarks = oSheet.Centermarks
        
        Dim aoDrawCurves4 As DrawingCurve
        oDrawViewCurves = oView.DrawingCurves(aoEdge4)
        Dim aoDrawCurves4Count = oDrawViewCurves.Count
        
        For i = 1 To aoDrawCurves4Count
            aoDrawCurves4 = oDrawViewCurves.Item(i)
			
			' If this curve is a 2D view of a circle, skip to the next curve
			Try
				If aoDrawCurves4.Segments(1).GeometryType <> Curve2dTypeEnum.kCircleCurve2d Then GoTo NextCurve
			Catch
				GoTo NextCurve
			End Try
            
            Dim oDim2 As Centermark
            Try
                If aoDrawCurves4.CurveType.ToString = "kCircleCurve" Then
                    oDim2 = oCenterMarks.Add(oSheet.CreateGeometryIntent(aoDrawCurves4))
					
					' If the new centermark is a duplicate, get rid of it
		            For j = 1 To oSheet.Centermarks.Count - 1
		                If Left(oSheet.Centermarks(j).Position.X, 10) = Left(oDim2.Position.X, 10) And _
							Left(oSheet.Centermarks(j).Position.Y, 10) = Left(oDim2.Position.Y, 10) Then oDim2.Delete
		            Next
                End If
            Catch
            End Try
NextCurve:
        Next
NextView:
    Next
End Sub
Message 6 of 26

admaiora
Mentor
Mentor

Great work @tdant 

 

Thanks for sharing!

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

_____________________________________________________________________________
Facebook | Twitter | Youtube

0 Likes
Message 7 of 26

WCrihfield
Mentor
Mentor
Accepted solution

Try this.  You would have to make sure your AutomatedCenterLineSettings are where you want them (which I believe could also be done within iLogic), but this should do what you want.  It doesn't delete any center marks that may already be there, but it's a good start.  Let me know how it works for you.

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews

Dim oViewOrient As ViewOrientationTypeEnum
Dim oACS As AutomatedCenterlineSettings
Dim oCLs As ObjectsEnumerator

For Each oView As DrawingView In oViews
	oViewOrient = oView.Camera.ViewOrientationType
	If oViewOrient = ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation Then
		Return
	ElseIf oViewOrient = ViewOrientationTypeEnum.kIsoBottomRightViewOrientation Then
		Return
	ElseIf oViewOrient = ViewOrientationTypeEnum.kIsoTopLeftViewOrientation Then
		Return
	ElseIf oViewOrient = ViewOrientationTypeEnum.kIsoTopRightViewOrientation Then
		Return
	Else
		oView.GetAutomatedCenterlineSettings(oACS)
		oACS.ApplyToBends = False
		oACS.ApplyToCircularPatterns = True
		oACS.ApplyToCylinders = False
		oACS.ApplyToFillets = False
		oACS.ApplyToHoles = True
		oACS.ApplyToPunches = True
		oACS.ApplyToRectangularPatterns = True
		oACS.ApplyToRevolutions = False
		oACS.ApplyToSketches = False
		oACS.ApplyToWorkFeatures = False
		'oACS.ArcAngleThreshold = 
		'oACS.CircularEdgeMaximumThreshold = 
		'oACS.CircularEdgeMinimumThreshold = 
		'oACS.FilletRadiusMaximumThreshold = 
		'oACS.FilletRadiusMinimumThreshold = 
		oACS.ProjectionNormalAxis = True
		oACS.ProjectionParallelAxis = True
		'oACS.RadiusThresholdPrecision = 
		oCLs = oView.SetAutomatedCenterlineSettings(oACS)
	End If
Next

	

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 26

DIMCWPDR
Contributor
Contributor

Could you please help with an iLogic rule for only the outside circle, as shown in the photo below?

 

 

DIMCWPDR_0-1723557107241.png

 

0 Likes
Message 9 of 26

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@DIMCWPDR , you can right click on the outer circle and use Capture Current State as shown below, and then use the iLogic Centermark snippet to do this:

 

Curtis_Waguespack_0-1723558418582.pngCurtis_Waguespack_1-1723558453002.png

 

Curtis_Waguespack_2-1723558602461.png

 

EESignature

Message 10 of 26

WCrihfield
Mentor
Mentor

Hi @DIMCWPDR.  That is not very much information to go by.

In order for any code to only create one Centermark, when there are multiple circles involved that would normally also get Centermarks, there would need to either be some manual user selection involved, or some very specific design information included within the code, such as circle radius / diameter upper and lower limits, and maybe even knowing exactly what type of feature that the circle represents.  So, would it be OK if the code asked you to pick that outer circle first, then place a Centermark on it by code after that?  If so, then there would not really be much need for the code to automate it, because the same can be done manually easier.  If you do not want to have to manually select that outer circle, then how else would one of us be able to find that outer circle by code when we know nothing about it?  We would need a lot more information than that to go on, such as an actual example drawing (with model being referenced in its views), or maybe a lot more details about the types of features and their sizes.  Explaining why this is needed may help also.  For example, we don't want to spend an hour writing code for something that will only be used once, in one drawing, then never used for anything else ever again, because it is far too specific.

 

You can review the online help pages for the Inventor API stuff in the links below for more insight into what is needed to create Centermarks on a sheet in a drawing.

Centermarks.Add 

Centermarks.AddByCenterOfGravity 

Centermarks.AddByWorkFeature 

AutomatedCenterlineSettings 

DrawingView.GetAutomatedCenterlineSettings 

DrawingView.SetAutomatedCenterlineSettings 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 26

DIMCWPDR
Contributor
Contributor

Hi Curtis_Waguespack

 

The code wroks very well many thaks to you.

Message 12 of 26

DIMCWPDR
Contributor
Contributor

Hallo curtis waguespack

I think I need help again with mig ilogic code. I need only the centermatks only as shown in the pic below:

 

DIMCWPDR_0-1723799716647.png

 

But when i run the rule i get the centermark in all the holes.

Can you please tell me which the text i have to tuen off or remove? 

Her is the rule:

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews

Dim oACS As AutomatedCenterlineSettings
Dim oCLs As ObjectsEnumerator

For Each oView As DrawingView In oViews
	
	If oViewOrient = ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation Then
		Return
	Else
		oView.GetAutomatedCenterlineSettings(oACS)
		oACS.ApplyToBends = False
		oACS.ApplyToCircularPatterns = True
		oACS.ApplyToCylinders = False
		oACS.ApplyToFillets = False
		oACS.ApplyToPunches = True
		oACS.ApplyToRectangularPatterns = True
		oACS.ApplyToRevolutions = False
		oACS.ApplyToSketches = False
		oACS.ApplyToWorkFeatures = False
		oACS.ProjectionNormalAxis = True
		oACS.ProjectionParallelAxis = True
		CLs = oView.SetAutomatedCenterlineSettings(oACS)
	End If
Next
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim VIEW1 = Sheet_1.DrawingViews.ItemByName("VIEW1")
Dim Face0 = VIEW1.GetIntent("Face0", PointIntentEnum.kCenterPointIntent)

Dim centermark = Sheet_1.Centermarks.Add("Hole Centermark", Face0)

 

0 Likes
Message 13 of 26

WCrihfield
Mentor
Mentor

Hi @DIMCWPDR.  As I mentioned in message 10 above, if you want to use the AutomatedCenterlineSettings for these types of tasks, then you would have to customize those settings according to the size of the feature you are targeting, and by what type of feature created it.  Review the following copy of your last code, and my comments on some of those lines.  If we know what type of feature created that largest round circular feature, then we can filter out all other types of features, leaving only that type of feature.  Also, your images do not indicate what size the largest circles are, or what size the smaller circles are, so only you would know that.  There are settings for minimum and maximum radius to be considered for getting things like centerlines and centermarks.  But we can not write those values in for you, because we can not tell now small to make the minimums, and how large to make the maximums.

 

Also note the changes I made to the 'If' statement just inside the loop of views.  It should now filter out any view set to that one specific view orientation, but when that one is encountered, it will now continue on to the next view, if any, instead of exiting out of the whole rule.  I also eliminated the last several lines, because they had no use anymore in this example.

 

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews
Dim oACS As AutomatedCenterlineSettings
Dim oCLs As ObjectsEnumerator
For Each oView As DrawingView In oViews
	If oView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation Then
		Continue For
	Else
		oView.GetAutomatedCenterlineSettings(oACS)
		'if you know the size of the largest radius, then set these next two settings
		'set Max circular Radius (in centimeters) to get a centerline / centermark
		oACS.CircularEdgeMaximumThreshold = 100
		'set Min circular Radius (in centimeters) to get a centerline / centermark
		oACS.CircularEdgeMinimumThreshold = 2
		'set Max fillet radius (in centimeters) to get a centerline / centermark
		oACS.FilletRadiusMaximumThreshold = 20
		'set Min fillet radius (in centimeters) to get a centerline / centermark
		oACS.FilletRadiusMinimumThreshold = 2
		oACS.ApplyToBends = False
		oACS.ApplyToCircularPatterns = False
		'if they were created using Hole feature, this would effect them
		oACS.ApplyToHoles = False
		'this next one would apply to all cylindrical faces
		oACS.ApplyToCylinders = False
		oACS.ApplyToFillets = False
		oACS.ApplyToPunches = False
		oACS.ApplyToRectangularPatterns = False
		'If the feature was created using Revolve feature
		oACS.ApplyToRevolutions = True 
		oACS.ApplyToSketches = False
		oACS.ApplyToWorkFeatures = False
		oACS.ProjectionNormalAxis = True
		oACS.ProjectionParallelAxis = True
		CLs = oView.SetAutomatedCenterlineSettings(oACS)
	End If
Next

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 26

WCrihfield
Mentor
Mentor

Hi @DIMCWPDR.  Here is also another code example which uses Inventor API and shows how a centermark can be added to a circular curve within a drawing view.  This example requires you to manually select the circular geometry within the view, then it will add the centermark for you.  Just as additional information about situations like this.

Dim sPrompt As String = "Pick a circular drawing view curve to add centermark to, or press ESC key to exit."
Dim oFilter = SelectionFilterEnum.kDrawingCurveSegmentFilter
Dim oPickedDCS As DrawingCurveSegment = ThisApplication.CommandManager.Pick(oFilter, sPrompt)
If oPickedDCS Is Nothing Then
	MsgBox("Nothing Selected, so exiting rule.", vbInformation, "iLogic")
	Return
End If
Dim oDCurve As DrawingCurve = oPickedDCS.Parent
Dim oView As DrawingView = oDCurve.Parent
Dim oSheet As Inventor.Sheet = oView.Parent
'Dim oDDoc As DrawingDocument = oSheet.Parent
If oPickedDCS.GeometryType = Curve2dTypeEnum.kCircleCurve2d OrElse
	oDCurve.CurveType = CurveTypeEnum.kCircleCurve Then
	Dim oGeomIntent As GeometryIntent = oSheet.CreateGeometryIntent(oDCurve, PointIntentEnum.kCenterPointIntent)
	oSheet.Centermarks.Add(oGeomIntent, True)
Else
	MsgBox("Selected Geometry was not a circle, so nothing happens.", vbInformation, "iLogic")
	Return
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 15 of 26

DIMCWPDR
Contributor
Contributor
Hi Curtis_Waguespack
For some reason, the code is not working for me. Nothing happens when I run it.
0 Likes
Message 16 of 26

DIMCWPDR
Contributor
Contributor

Hi WCrihfield

Thanks very much for the code, but I prefer the kind of code that, when I run it, will define all the center marks for me

 

Can you help me with that?

0 Likes
Message 17 of 26

WCrihfield
Mentor
Mentor

We can definitely write code that will apply centermarks to pretty much anything in every drawing view that is capable of getting a centermark placed on it.  However, if you only want certain specific things to get them, and not others, that is where the complication comes in.  We simply need a way to identify the specific geometry that you want to get centermarks, and a way to identify the specific geometry that would normally also get a centermark, but you do not want them to get centermarks, such as the circular pattern of holes in that part.  The code we write must be extremely specific or it will not work, so without extremely specific information (from you or a sample drawing), that can be nearly impossible to write the code for.

 

In the earlier example that used 'Capture Current State', that uses powerful iLogic functionality (that we users do not have the source code for) to actually assign a generic name to the geometry in the model that the selected view geometry represents.  Then we can use that name later in the code, to help identify that specific piece of geometry, for things like GeometryIntent, which is used for attaching annotations to view geometry.  However, what most folks do who want to automate their drawings is, prepare their models ahead of time, by assigning specific names to all the pieces of geometry that they will want to attach drawing dimensions and / or other drawing annotations to in the drawing later.  Then when in the drawing later, they can find those specific pieces of geometry within their views using the names that they assigned to them in the model.  In the examples above, we do not know if you have assigned any names to any of that geometry in your model, so we just assumed that you had not done that yet.  But that would make situations like this much easier to manage.  It gives you more control over being able to find and use specific view geometry for attaching dimensions and annotations to them in your drawing.  Without that we are 'flying blind' so to speak.  I hope you understand what I mean with all of this.

In a part, you can select a Face, Edge, or Vertex, then right-click, and within the right-click menu will be an option named 'Assign Name...'.  That is where you assign names to geometry, so you can easily find it again later by code.  We can also assign names to stuff by code, using Attributes, which is what that system uses behind the scenes.  But assigning names to geometry should be done by someone who is extremely familiar with what that geometry is, so that the names are most meaningful to them, so they know which ones are which later.

  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 18 of 26

DIMCWPDR
Contributor
Contributor

Can I provide you with my .ipt and .idw files so you can take a look at them? The problem is that I have many gasket drawings like this for my project, and I need to automatically generate centerlines and centermarks as shown below

 

I only need this centerlins as following pic below

 

DIMCWPDR_0-1723815481247.png

 

 

0 Likes
Message 19 of 26

DIMCWPDR
Contributor
Contributor

Here is my files

0 Likes
Message 20 of 26

DIMCWPDR
Contributor
Contributor

 

 

0 Likes