Rotate Sketched Symbol with iLogic

Rotate Sketched Symbol with iLogic

Anonymous
Not applicable
1,055 Views
6 Replies
Message 1 of 7

Rotate Sketched Symbol with iLogic

Anonymous
Not applicable

Hej

 

I would like to rotate existing Sketched Symbol with iLogic. I can scale it with this code, but I can't use the same to rotate.

 

For Each sketched As SketchedSymbol In oSheet.SketchedSymbols
      If (sketched.Name = "Snit_C") Then
          sketched.Scale = 2
        sketched.Rotate = 30
        
      End If
Next

 

It get error:

Error in rule: SymbolRul, in document: TS_FG_BR.idw
Det offentlige medlem 'Rotate' i typen 'SketchedSymbol' blev ikke fundet.

 

If anyone can help. It will be nice.

Lilia

0 Likes
Accepted solutions (2)
1,056 Views
6 Replies
Replies (6)
Message 2 of 7

philippe.leefsma
Alumni
Alumni
Accepted solution

The correct spelling of the property is "Rotation" and not "Rotate".

 

Check the Help Files in case of a doubt.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

Anonymous
Not applicable
Accepted solution
Thank you, Philippe !!!
It has helped. The reason I spelled it that way in the program.
 
Udklip.JPG
 
 
Regards, Lilia.
0 Likes
Message 4 of 7

Anonymous
Not applicable

I want to achieve something very similar. I have a symbol on my drawing and I want a rule to change it's scale to match the scale of another view I have

Something like this:

SymbolScale ("Scaled Man") = ActiveSheet.View(View(2)).ScaleString

 

So far I have copy pasted what you have, see below but get errors

For Each sketched As SketchedSymbol In oSheet.SketchedSymbols
      If (sketched.Name = "Scaled Man") Then
          sketched.Scale = 2
sketched.Rotation = 30
End If Next 

I'm very new to iLogic so don't really understand these errors:

Error on Line 1 : Type 'SketchedSymbol' is not defined.

Error on Line 1 : 'oSheet' is not declared. It may be inaccessible due to its protection level.

 

Maybe there's something even simpler I could do?

0 Likes
Message 5 of 7

MechMachineMan
Advisor
Advisor
For Each oSheet As Sheet in ThisApplication.ActiveDocument.Sheets

For
Each sketched As SketchedSymbol In oSheet.SketchedSymbols If (sketched.Name = "Scaled Man") Then sketched.Scale = 2
sketched.Rotation = 30
End If Next 
Next

Untested, but should work. You were missing the declaration for oSheet, as the plain english in the error stack suggests. oSheet needs a declaration as it is a variable created by the user and not native to the API.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 7

Anonymous
Not applicable

Thanks for that explanation, it works perfect now for that appliction.

I've encountered another issue however, I want my sketched symbol scale to be set the same as another drawing view scale.

I have the following code but get this error: "Conversion from string "1/15.25" to type 'Double' is not valid."

 

For Each oSheet As Sheet In ThisApplication.ActiveDocument.Sheets

  For Each sketched As SketchedSymbol In oSheet.SketchedSymbols
      If (sketched.Name = "Scaled Man") Then
          sketched.Scale = ActiveSheet.View("ELEVATION").ScaleString
         
      End If
  Next 
Next

 How can I convert this to a 'double'?

 

I have this piece of code which applies the scale from one view to another, which I've tried to use in a similar way above. However I understand in this instance it's simpler as I'm going from string to string.

ActiveSheet.View("PERSPECTIVE").ScaleString = ActiveSheet.View("ELEVATION").ScaleString  

 

0 Likes
Message 7 of 7

Anonymous
Not applicable

Soke too soon. No error when I remove the word 'String' from this line

 

sketched.Scale = ActiveSheet.View("ELEVATION").Scale

 

0 Likes