Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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

Posted

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.

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

Sorry, I didn't know that there was a command to update that. Thanks for the information. :)

Posted

I think you can use BATTMAN too but I've never used that command.

Posted

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.

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

 

Battman.jpg

Posted

Now the only thing left to know is which one is faster to use :P

Posted

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.

Posted

Lol... Well hope you see him someday :D

 

Cheers and Beers !

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...