onyx Posted October 31, 2013 Posted October 31, 2013 I would like to change sub block from a visibility after setting it. Here an example of code to get the right visibility, I don't really know how to update a sub block by name or by handle(seems to change inside dynamic block). Any help will be greatly appreciated. Dim Block As AcadBlock Dim BlockRef As AcadBlockReference Dim DynEntBlock As AcadEntity Dim DynObjRefH As IAcadBlockReference Dim DynObjReferencePropH As AcadDynamicBlockReferenceProperty Dim attrib As Variant Dim AcadObj As Object Handle = "CD7F" PropertyReferenceValue = "2 Motor" 'Find an object from a given handle Set DynEntBlock = ThisDrawing.HandleToObject(Handle) T = DynEntBlock.GetDynamicBlockProperties 'Get Dynamic attributes For Ti = LBound(T) To UBound(T) Set DynObjReferencePropH = T(Ti) 'If PropertyValue = "SFan - VFD no Bypass - CV" Then If DynObjReferencePropH.PropertyName = "Visibility1" Then DynObjReferencePropH.Value = PropertyReferenceValue '"SVFD - no BYPASS - CV" '.... 'Iteration through sub block name ??? 'If blockName.Name = "Fuse_3p" Then ??? If attrib.TagString = "RAT1" Then 'Attribute Name attrib.TextString = "15A" 'Attribute Value End If 'End if End If Next 'ThisDrawing.Regen acActiveViewport 'ThisDrawing.Regen true End Sub Quote
Tuns Posted October 31, 2013 Posted October 31, 2013 1. Welcome to Cad Tutor. 2. You should put that in code tags before Hulk comes to smash you. 3. If you add or remove an attribute in a block that already exists in the drawing, that block will not update. You have to remove it and then add the new block with the attributes in it. It will update the dynamic inputs, but wont update the block when adding/removing attributes. Are you trying to add an attribute to your other visibility? I may be completely wrong in my assumption here. Quote
onyx Posted October 31, 2013 Author Posted October 31, 2013 The block inside the visibility has a few block and I would like to read the attribute of a specific block and change it to another value. I'm not trying to add attributes to the block. The ... and ??? must be surely replaced by something right in my code. I'm able to switch on the visibility "SVFD - no BYPASS - CV", that visibility contains a few blocks including themselves a few attributes. Thanks for your reply Quote
Tuns Posted November 4, 2013 Posted November 4, 2013 You can probably change it all out with a script that uses the ATTEDIT command. I can't say for certain if it can change attributes in a hidden visibility but it's worth a try. Quote
dbroada Posted November 4, 2013 Posted November 4, 2013 3. If you add or remove an attribute in a block that already exists in the drawing, that block will not update. You have to remove it and then add the new block with the attributes in it. Not true. You need to ATTSYNC the block to add the attribute to ALL instances of the block. If you do not ATTSYNC only future blocks will have the correct definition. Quote
Tuns Posted November 4, 2013 Posted November 4, 2013 Sorry, I didn't know that there was a command to update that. Thanks for the information. Quote
dbroada Posted November 4, 2013 Posted November 4, 2013 I think you can use BATTMAN too but I've never used that command. Quote
CadFrank Posted November 4, 2013 Posted November 4, 2013 I think BATTMAN won't update, with that command you can choose the order of the attributes or change their texte,size and styles. I haven't played alot with it though. But ATTSYNC is mostly useful. Quote
dbroada Posted November 4, 2013 Posted November 4, 2013 I think BATTMAN won't update, with that command you can choose the order of the attributes or change their texte,size and styles. I haven't played alot with it though. But ATTSYNC is mostly useful. as I said above, I've never used it but the dialogue box suggests that it will sync. Quote
CadFrank Posted November 4, 2013 Posted November 4, 2013 Now the only thing left to know is which one is faster to use Quote
dbroada Posted November 4, 2013 Posted November 4, 2013 for me, ATTSYNC. My fingers can type that without thinking. I always leave one of the "T"s out of the other command expecting my favourite superhero to show up. Quote
CadFrank Posted November 4, 2013 Posted November 4, 2013 Lol... Well hope you see him someday Cheers and Beers ! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.