Hi,
I'm using iLogic to create a drawing with annotations, this works fine using the workpoints method, simplified example below:
Dim oWP1 As WorkPoint = oWorkPoints.Item("WP1name") 'Define workpoints
Dim oWP2 As WorkPoint = oWorkPoints.Item("WP2name")
Dim oV1Cm1, oV1Cm2 As CenterMark 'Create centermarks on workpoints
oV1Cm1 = oCMs.AddByWorkFeature(oWP1, oView1)
oV1Cm2 = oCMs.AddByWorkFeature(oWP5, oView1)
Dim oV1Int1 As GeometryIntent = oSheet.CreateGeometryIntent(oV1Cm1) 'create geom intents
Dim oV1Int2 As GeometryIntent = oSheet.CreateGeometryIntent(oV1Cm2)
oPtText_V1_p1 = oTG.CreatePoint2d(oView1.Center.X, (oView1.Top + 1)) 'annotation position for placement
oDimTypeH = DimensionTypeEnum.kHorizontalDimensionType 'horizontal placement 'annotation orientation
oV1Dim1 = Sheet.DrawingDimensions.GeneralDimensions.AddLinear(oPtText_V1_p1, oV1Int1, oV1Int2, oDimTypeH) 'place annotation
In some configurations of the assembly specific Parts are supressed, but the iLogic code still creates the Centremarks of the supressed Parts, leaving some floating marks without annotation on my drawing, example below.
This is no big problem, but it would be more stylish to not show these in case the part they originate from is supressed, to achieve this i tried the following:
use some simple logic to check if the part is supressed, E.g.
If part1 = unsupressed
Dim oWP1 As WorkPoint = oWorkPoints.Item("WP1name") 'Define workpoints
Dim oWP2 As WorkPoint = oWorkPoints.Item("WP2name")
else
end if
'rest of the code...
This failed, which makes sense, because the centermarks cant be created if theres no workpoints to create them from. I would basically have to repeat this 'if statement check' for every single step in creating the annotation, because otherwise the next step will throw an error, this is not ideal...
So my question:
Is there a simpeler way of removing these unused centermarks? Any ideas?
Looking for some general simple solution i can put in the end of my code if possible:
For Each CenterMark in oDrawingDoc
If Centremark = *something* Then ' *something* = not used as basepoint for creating a linear dimension
CenterMark.Supress
End if
Next
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by JhoelForshav. Go to Solution.
Hi @Daan_M
Since we know that the centermarks attached entity will be of type workpoint, we can use the workpoints healthstatus to see if it has been suppressed. Try this 🙂
For Each oCM As Centermark In ActiveSheet.Sheet.Centermarks 'You probably have a variable for your sheet already If oCM.Attached AndAlso TypeOf (oCM.AttachedEntity) Is WorkPoint _ AndAlso oCM.AttachedEntity.HealthStatus = HealthStatusEnum.kSuppressedHealth Then oCM.Visible = False Next
EDIT:
You're talking about parts being suppressed though so I think maybe we should add to check if its WorkPoint or WorkPointProxy, because I believe the points will in fact be of type WorkPointProxy:
For Each oCM As Centermark In ActiveSheet.Sheet.Centermarks 'You probably have a variable for your sheet already If oCM.Attached AndAlso (TypeOf (oCM.AttachedEntity) Is WorkPoint Or TypeOf(oCM.AttachedEntity) Is WorkPointProxy) _ AndAlso oCM.AttachedEntity.HealthStatus = HealthStatusEnum.kSuppressedHealth Then oCM.Visible = False Next
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Here are a couple quick and simple ideas, that come to mind:
> As you create the Centermarks, add the to a collection. Then as they're being used to create dimensions, add those Centermarks to second collection. Then loop through the two collections, and whichever ones in the first collection that aren't found in the second collection, you can either delete (oCM.Delete) or hide (oCM.Visible = False).
> Another idea would be to add all the Centermarks to a collection (as in the last idea), then add all the dimensions to another collection as you create them. Then when they have all been created, loop through each dimension (define each object within as a LinearGeneralDimension, since they are all added using AddLinear), checking their oLinDim.IntentOne.Geometry and oLinDim.IntentTwo.Geometry properties. Checking to see if each Centermark in the collection is being used. Any Centermarks (in that collection) that were not used by the end of the Loops can be deleted or hidden.
Wesley Crihfield
(Not an Autodesk Employee)
@Daan_M @JhoelForshav Actually, I think your method of checking the HealthStatus of the WorkPoint would be more useful at the beginning of the code before the Centermark is created. Then just don't create the Centermark if the WorkPoint is suppressed. Also, I think checking its .Attached property, would just confirm it is attached to the WorkPoint it is based on, not necessarily attached to one of the created dimensions.
Wesley Crihfield
(Not an Autodesk Employee)
Checking if it's attached is just to make sure it has an attached entity. If it hasn't the code would fail checking the attached entitys type...
I just gave an answer to how he can hide the centermarks with a for loop at the end of the code as @Daan_M requested. I don't know how his process will work, maybe he wants to be able to show the centermarks again if the parts gets unsuppressed. Something like:
For Each oCM As Centermark In ActiveSheet.Sheet.Centermarks 'You probably have a variable for your sheet already If oCM.Attached AndAlso (TypeOf (oCM.AttachedEntity) Is WorkPoint Or TypeOf (oCM.AttachedEntity) Is WorkPointProxy) If oCM.AttachedEntity.HealthStatus = HealthStatusEnum.kSuppressedHealth oCM.Visible = False Else oCM.Visible = True End If End If Next
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
@JhoelForshav @WCrihfield , Thank you both for the replies and the help thinking towards a solution. i'll need some time to look into it to understand the way it works, ill come back with the outcome later.
Ps; If there is an easy solution it doesn't matter where it is placed in the code, i just assumed it would be most easy to place something at the end, compared to what i was trying to do (make 'if statements' throughout every step my code).
Addition: The drawing code is ran once, the code to create the 2D is inside a drawing template. The template is opened, the code is executed once, the drawing is saved with a certian name and closed. (this is repeated everytime the assembly gets updated.
Cheers!
Just a question @Daan_M
Are these workpoints you're using on part level or assembly level?
If they're on assembly level they wont be suppressed just because the component they're attached to is. Then we'd have to go through the relationships of the workpoint instead, checking if the occurrence it's constrained to is suppressed...
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
The workpoints are inside the Assembly Document.
The more practical solution:
I already check which components are supressed inside the drawingcode for other reasons, so i guess i could use this and manually put some statements at the end of my code pointing out which centermarks to supress. E.g:
If Flange_Part.Supressed = true
oCM_flange1.visible=false
oCM_flange2.visible=false
end if
Ofcourse the more 'pretty and general' solution i was aiming for in my initial comment would be to make the centermarks that are not used in creating dimensions invisible, without having to point them out for each part seperately and creating statements
Then I assume the workpoints are constrained to the occurrences of the parts...
Try this at the end of the code. Should work 🙂
For Each oCM As Centermark In ActiveSheet.Sheet.Centermarks 'You probably have a variable for your sheet already If oCM.Attached AndAlso TypeOf (oCM.AttachedEntity) Is WorkPoint Try For Each oConst As AssemblyConstraint In DirectCast(oCM.AttachedEntity, WorkPoint).Dependents.OfType(Of AssemblyConstraint) If oConst.AffectedOccurrenceOne.Suppressed Then oCM.Visible = False Next Catch End Try End If Next
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hi @JhoelForshav, looks like the elegant solution i was trying to find. I haven't yet got it to work, it runs without error, but the Centermarks are still there. To give context, i have
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.Sheets.Item(1)
Dim oCMs As Centermarks = oSheet.Centermarks
And changed your code to fit it:
For Each oCMs In oSheet.Centermarks
If oCMs.Attached AndAlso TypeOf (oCMs.AttachedEntity) Is WorkPoint
For Each oConst As AssemblyConstraint In DirectCast(oCMs.AttachedEntity, WorkPoint).Dependents.OfType(Of AssemblyConstraint)
If oConst.AffectedOccurrenceOne.Suppressed Then oCMs.Visible = False
Next
End If
Next
Ok... Could you share a picture of your assembly tree with the parts suppressed so I can see the structure? 🙂
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Assuming both sections of code you posted are in the same rule...It looks like you need to create a new variable for a single Centermark object, instead of reusing the variable which represents the whole collection of Centermarks that exist on the sheet.
The variable oCMs is representing all the Centermarks on the oSheet.
You need to create a new variable, similar to the example Jhoel has posted:
Dim oCM As Centermark
then
For Each oCM In oCMs
or
For Each oCM As Centermark In oCMs
Then replace oCMs throughout the rest of that block of code with the new (singular) variable, oCM.
Wesley Crihfield
(Not an Autodesk Employee)
Well spotted @WCrihfield!
You could just run the code exactly as i posted it @Daan_M to see if it works. But then change it according to @WCrihfield's suggestion to make it look better 🙂
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
@JhoelForshav @WCrihfield Works perfectly, Points for both of you!
Have a nice weekend
Can't find what you're looking for? Ask the community or share your knowledge.